ADDCOLUMNS DAX Function (Table manipulation)

Returns a table with new columns specified by the DAX expressions.

Syntax

ADDCOLUMNS ( <Table>, <Name>, <Expression> [, <Name>, <Expression> [, … ] ] )
Parameter Attributes Description
Table
Iterator

The table to which new columns are added.

Name Repeatable

The name of the new column to be added.

Expression
Row Context
Repeatable

The expression for the new column to be added.

Return values

Table An entire table or a table with one or more columns.

A table with all its original columns and the added ones.

Remarks

ADDCOLUMNS does not preserve the data lineage of the added columns for a following context transition, even if a column expression is a simple column reference. However, the data lineage of the column added is effective for NATURALLEFTOUTERJOIN and NATURALINNERJOIN.

» 8 related articles
» 1 related function

Examples

--  ADDCOLUMNS is an iterator that returns its first argument
--  after adding the column specified.
--  New columns are computed in the row context of ADDCOLUMNS,
--  you need to invoke context transition to generate a filter
--  context, if needed.
EVALUATE
FILTER (
    ADDCOLUMNS (
        VALUES ( 'Date'[Calendar Year] ),
        "@Year Number",         INT ( RIGHT ( 'Date'[Calendar Year], 4 ) ),
        "@Amount",              [Sales Amount],
        "@Quantity Wrong",      SUM ( Sales[Quantity] ),
        "@Quantity Correct",    CALCULATE ( SUM ( Sales[Quantity] ) )
    ),
    [@Amount] > 0
)
Calendar Year @Year Number @Amount @Quantity Wrong @Quantity Correct
2007-01-01 2007 11,309,946.12 140,180 44,310
2008-01-01 2008 9,927,582.99 140,180 40,226
2009-01-01 2009 9,353,814.87 140,180 55,644

Related articles

Learn more about ADDCOLUMNS in the following articles:

Related functions

Other related functions are:

Last update: Mar 13, 2024   » Contribute   » Show contributors

Contributors: Alberto Ferrari, Marco Russo, Kenneth Barber,

Microsoft documentation: https://docs.microsoft.com/en-us/dax/addcolumns-function-dax

2018-2024 © SQLBI. All rights are reserved. Information coming from Microsoft documentation is property of Microsoft Corp. » Contact us   » Privacy Policy & Cookies

Context Transition

This function performs a Context Transition if called in a Row Context. Click to read more.

Row Context

This expression is executed in a Row Context. Click to read more.

Iterator

Not recommended

The use of this function is not recommended. See Remarks and Related functions for alternatives.

Not recommended

The use of this parameter is not recommended.

Deprecated

This function is deprecated. Jump to the Alternatives section to see the function to use.

Volatile

A volatile function may return a different result every time you call it, even if you provide the same arguments. Click to read more.

Deprecated

This parameter is deprecated and its use is not recommended.

DirectQuery compatibility

Limitations are placed on DAX expressions allowed in measures and calculated columns.
The state below shows the DirectQuery compatibility of the DAX function.

Contribute

Want to improve the content of ADDCOLUMNS? Did you find any issue?
Please, report it us! All submissions will be evaluated for possible updates of the content.


This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.