Downloads
DAXTable constructionIntermediate

SELECTCOLUMNS

Returns a new table with only the columns you name, each one built from an expression.

Syntax
SELECTCOLUMNS(<table>, <name>, <expression> [, <name>, <expression>] ...)

Returns: A table.

What it does

SELECTCOLUMNS builds a new table with the columns you want, using the names you give. Each column comes from an expression that runs for each row. Use it to shape a table before a union, to rename columns so they match another table, or to keep a few columns from a wide table. Unlike ADDCOLUMNS, it drops every column you do not name.

Syntax and arguments

Example

A store directory with friendly column headers, as a calculated table.

Store Directory =
SELECTCOLUMNS (
    Stores,
    "Store", Stores[StoreName],
    "Country", Stores[Country],
    "Type", Stores[StoreType]
)

The new table has three columns with the names you chose. Other columns in Stores are not included.

Example: a second use

A line-level margin table with only the product key and the margin on each sales line.

EVALUATE
SELECTCOLUMNS (
    Sales,
    "ProductKey", Sales[ProductKey],
    "Line Margin", Sales[SalesAmount] - Sales[TotalCost]
)

Each sales line becomes one row with two columns. A fact table has many rows, so run this as a query for a check, rather than storing it as a calculated table.

Things to watch

In business terms

Mapping source column names to report headers, building a clean list of accounts for an export, and combining two source tables into one with matching column names before a total is taken.

Related functions

All DAX functions · View as Markdown · DAX fundamentals