ADDCOLUMNS Function (DAX)
How does the ADDCOLUMNS function (DAX) work?
This is an aggregation function used to add columns to DAX tables. It adds calculated columns to any given table or table expression. This function will return a table with all its original columns and the added ones.
ADDCOLUMNS Formula Syntax
ADDCOLUMNS(
<table>, <name>, <expression> [, <name>, <expression>]….
)
How do you use the ADDCOLUMNS function?
This function is equivalent to adding a calculated column to a table; the only real difference is that ad hoc columns are calculated only once (they’re not stored in your model).
Related Blog Posts
Considerations when using the ADDCOLUMNS function
It has 3 parameters to work with: the table to which the new columns are added, the name given to the new column and is enclosed in double-quotes, and the expression that returns a scalar expression which is evaluated for every row of the table.
Related Video Tutorials
Formula examples using the ADDCOLUMNS function
= ADDCOLUMNS ( Products,”East_Sales”,
SUMX (RELATEDTABLE (East_Sales),
IF([Product] = East_Sales[Product], East_Sales[Sales Amount],0)
)
)
= EVALUATE
ADDCOLUMNS (
Species,
“Number transactions”,
COUNTROWS ( RELATEDTABLE ( ‘Transaction’ ) )
)
= ADDCOLUMNS (
Products,”East_Sales”,
SUMX (RELATEDTABLE(East_Sales),
IF([Product] = East_Sales[Product], East_Sales[Sales Amount],0)
)