SELECTCOLUMNS

How to Use the Power BI DAX function SELECTCOLUMNS

In this article, we will focus on the DAX function SELECTCOLUMNS. This function is used to create a new table by selecting specific columns from an existing table. Let’s dive into the details of this function.

Syntax

The syntax for SELECTCOLUMNS function is as follows:


SELECTCOLUMNS(❰table❱, ❰column1❱, ❰expression1❱[, ❰column2❱, ❰expression2❱, …])


The function takes the following arguments:

- `❰table❱`: The name of the existing table from which the columns are to be selected.

- `❰column1❱`, `❰column2❱`, ...: The name of the columns to be included in the new table.

- `❰expression1❱`, `❰expression2❱`, ...: The expressions used to create the values for the new columns.

Example

Suppose we have a table named `Sales` with columns `Product`, `Category`, `Price`, and `Quantity`. We want to create a new table with only two columns `Product` and `Revenue` (which is calculated as `Price * Quantity`). We can use the SELECTCOLUMNS function to achieve this as follows:


Revenue = SELECTCOLUMNS(Sales, “Product”, Sales[Product], “Revenue”, Sales[Price] * Sales[Quantity])


In this example, we have created a new table named `Revenue` with only two columns `Product` and `Revenue`. The `Product` column is copied from the `Sales` table, whereas the `Revenue` column is calculated as the product of `Price` and `Quantity` columns from the `Sales` table.

Benefits of SELECTCOLUMNS

The SELECTCOLUMNS function has several benefits, some of which are listed below:

1. Select specific columns

The SELECTCOLUMNS function allows users to select only the columns they need from an existing table, instead of loading the entire table. This can help reduce the data size and improve the performance of the report.

2. Create custom calculations

Users can use the SELECTCOLUMNS function to create custom calculations that are not available in the existing table. This can help users gain insights into the data that were not possible before.

3. Improve data model

Using the SELECTCOLUMNS function can help improve the data model by creating new tables with only the required columns. This can help simplify the data model and make it easier to understand and maintain.

4. Reusability

Users can reuse the SELECTCOLUMNS function in multiple reports and dashboards, making it a powerful tool for data transformation.

The SELECTCOLUMNS function is a powerful feature of the DAX language that can help users select specific columns from an existing table and create new tables with custom calculations. By using this function, users can improve the performance of their reports, gain new insights into their data, and simplify their data model.

Power BI DAX Training Courses by G Com Solutions (0800 998 9248)

Upcoming Courses

Contact Us

    Subject

    Your Name (required)

    Company/Organisation

    Email (required)

    Telephone

    Training Course(s)

    Your Message

    Upload Example Document(s) (Zip multiple files)