📄ADDCOLUMNS
Imagine you`re working with a dataset in Power BI or Excel and need some extra insights. The ADDCOLUMNS function in DAX acts like a magic calculator for your tables. It lets you create new columns packed with custom formulas and expressions, tailored to each row of data.
Here`s how it works:
Pick your table: ADDCOLUMNS works on any existing table or even a table expression you`ve built using other DAX magic.
Name your creation: Give your new column a descriptive name in double quotes, making it easy to understand what it represents.
Craft your calculation: Here`s where the power lies. Write a DAX expression that can be anything from a simple formula to a complex calculation involving other columns or functions. This expression will be evaluated for every single row in the table, giving you a unique value for each row in the new column.
Repeat for more columns (optional): Need even more analysis firepower? ADDCOLUMNS lets you add multiple columns in one go. Just follow the same name-expression pattern for each additional column you design.
ADDCOLUMNS returns a new table with all the original columns plus your new calculated ones. This allows you to analyze your data from fresh perspectives without modifying the original table itself.
In the following example, we created a table from another table named ABS, which was created for
ABS formula. And then we created another column named "New Column" by multiplying ABS column in ABS table with 2.