Skip to content
Home » DAX » SELECTCOLUMNS DAX Function

SELECTCOLUMNS DAX Function

Selectcolumns DAX
5/5 - (4 votes)

The SELECTCOLUMNS function returns a table with new columns specified by the user.

Syntax

SELECTCOLUMNS(<Table>, <Name>, <Expression>, <Name>, …)

Parameters

Table: Any DAX expression that returns a table.
Name: The name given to the column, enclosed in double quotes.
Expression: Any expression that returns a scalar value, like a column reference, integer, or string value.

Let’s get started

Import below dataset into Power BI Desktop

Region Country City Sales
North India Delhi 1000
North India Chandigarh 1500
South India Bangalore 2000
South India Chennai 2500
East India Kolkata 1800
West India Mumbai 3500
West India Pune 1200




Example Scenario:

Suppose you have a table named Sales with columns Region, Country, City, and Sales, and you want to create a new table with only the Region,  Sales, along with two new columns:

  1. CountryCity: A concatenation of the Country and City columns.
  2. Discount: Creates a column named Discount with values calculated as 10% of the sales.

Now follow these steps:

Step-1: Click on the Modeling tab in the ribbon and then click on New Table.

Create a new table in Power BI
Create a new table in Power BI

Step-2: In the formula bar, enter the SELECTCOLUMNS DAX function to create the new table. For example:

NewTable =

SELECTCOLUMNS(
    Sales,
    "Region", Sales[Region],
    "CountryCity", 'Sales'[Country] & " " & 'Sales'[City],
    "Sales", Sales[Sales],
    "Discount", 'Sales'[Sales] * 0.1
)
Step-3: After pressing Enter, a new table named NewTable will be created. This table will have the following structure:
SELECTCOLUMN DAX Function Example
SELECTCOLUMN DAX Function Example

I hope you now have a better understanding of how to create a new table with specified columns using the SELECTCOLUMN function.

Another examples:

Scenario 1: Using SELECTCOLUMNS with FILTER

FilteredSales =
SELECTCOLUMNS(
FILTER(
Sales,
Sales[Sales] > 2000
),
"Region", Sales[Region],
"CountryCity", Sales[Country] & " " & Sales[City],
"Sales", Sales[Sales],
"Discount", Sales[Sales] * 0.1
)

Scenario 2:Using SELECTCOLUMNS with FILTER

CategorizedSales =
SELECTCOLUMNS(
ADDCOLUMNS(
Sales,
"SalesCategory", IF(Sales[Sales] > 3000, "High", "Low")
),
"Region", Sales[Region],
"CountryCity", Sales[Country] & " " & Sales[City],
"Sales", Sales[Sales],
"SalesCategory", [SalesCategory]
)

I hope you enjoyed the post. Your valuable feedback, questions, or comments about this post are always welcome.

Loading

1 thought on “SELECTCOLUMNS DAX Function”

  1. nice topic you covered Brother Kudos.
    can i know what is the key difference between selected columns and summarize function.

Leave a Reply

Discover more from Power BI Docs

Subscribe now to keep reading and get access to the full archive.

Continue reading