

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 4
click for more info
Not enough gems
Cost: 6 gems
1: DAX
incomplete
2: Logical Functions – IF
incomplete
3: SWITCH Function
incomplete
4: Time Intelligence Functions
incomplete
5: More Time Functions
incomplete
6: Add Columns
incomplete
7: Aggregations
incomplete
8: Aggregations As Measures
incomplete
9: Iterators
incomplete
10: Calculated Columns vs. Measures
incomplete
11: Context in DAX
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
We've used the SELECTCOLUMNS function in the DAX query view to return specific columns from our table. The ADDCOLUMNS function returns the columns we specify as well as all the original columns.
This returns all the original sales columns, as well as a new column called discounted_quantity:
EVALUATE
ADDCOLUMNS(
sales,
"discounted_quantity", sales[sale_quantity] * (1 - sales[sale_discount])
)
When using a function like SELECTCOLUMNS or ADDCOLUMNS, you can't reference a related table directly. To do so, you need to use the RELATED function:
EVALUATE
SELECTCOLUMNS(
users,
"user_name", users[name],
"user_server", RELATED('servers'[name]),
"user_created_at", RELATED('dates'[created_at])
)
You can order the data in a DAX expression with the ORDER BY keywords:
EVALUATE
SELECTCOLUMNS(
users,
"user_name", users[name],
"user_server", RELATED('servers'[name]),
"user_created_at", RELATED('dates'[created_at])
)
ORDER BY
[user_created_at] DESC
We want to calculate the "time since Eshopp upgrade" for all sales. Eshopp's website went through a big migration, and management wants all sales tagged with the number of days before or after the change.