A
C
- CALCULATE
- CALCULATETABLE
- CALENDAR
- CALENDARAUTO
- CEILING
- CHISQ.DIST
- CHISQ.DIST.RT
- CHISQ.INV
- CHISQ.INV.RT
- CLOSINGBALANCEMONTH
- CLOSINGBALANCEQUARTER
- CLOSINGBALANCEYEAR
- COALESCE
- COLUMNSTATISTICS
- COMBIN
- COMBINA
- COMBINEVALUES
- CONCATENATE
- CONCATENATEX
- CONFIDENCE.NORM
- CONFIDENCE.T
- CONTAINS
- CONTAINSROW
- CONTAINSSTRING
- CONTAINSSTRINGEXACT
- CONVERT
- COS
- COSH
- COT
- COTH
- COUNT
- COUNTA
- COUNTAX
- COUNTBLANK
- COUNTROWS
- COUNTX
- COUPDAYBS
- COUPDAYS
- COUPDAYSNC
- COUPNCD
- COUPNUM
- COUPPCD
- CROSSFILTER
- CROSSJOIN
- CUMIPMT
- CUMPRINC
- CURRENCY
- CURRENTGROUP
- CUSTOMDATA
D
E
I
N
O
P
R
S
- SAMEPERIODLASTYEAR
- SAMPLE
- SEARCH
- SECOND
- SELECTCOLUMNS
- SELECTEDMEASURE
- SELECTEDMEASUREFORMATSTRING
- SELECTEDMEASURENAME
- SELECTEDVALUE
- SIGN
- SIN
- SINH
- SLN
- SQRT
- SQRTPI
- STARTOFMONTH
- STARTOFQUARTER
- STARTOFYEAR
- STDEVX.P
- STDEVX.S
- STDEV.P
- STDEV.S
- SUBSTITUTE
- SUBSTITUTEWITHINDEX
- SUM
- SUMMARIZE
- SUMMARIZECOLUMNS
- SUMX
- SWITCH
- SYD
T
U
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.