DAX - Tables Flashcards
How can you include columns from another table to iterate over?
You must use RELATED or RELATEDTABLE functions to bring the data into the table you want to iterate over
SUMMARIZE syntax
SUMMARIZE(TableName, GroupByColumn1, GroupByColumn2, GroupByColumn…, Name1, Expression1, Name2, Expression2…)
SUMMARIZE example
SUMMARIZE(
Sales, //Table
DateTime[CalendarYear], //Group By 1, ProductCategory[ProductCategoryName],
//Group By 2,
“Sales Amount”, //Name1
SUM(Sales[SalesAmount]), //Expression1
“Discount Amount (USD)”, //Name2
SUM(Sales[DiscountAmount]) //Expression2
)
How does the SUMMARIZE function work?
It creates a summary table by grouping data based on one or more columns.
How do you clone a table using DAX?
ClonedTableName=ALL(Original_Table_Name)
Example
Sales Data=ALL (Sales)
Writing a long sentence to left justify
Why would you want to clone a table?
To perform manipulation or analysis on data while preserving the original records.
What does the cloned table inherit?
The cloned table inherits the Original table’s:
- Columns
- Data
- Relationiships
What is the difference between a cloned table and a calculated table?
Cloned Tables
Simple duplicates of the original table
Calculated tables created based on
- Calculations
- Transformations
- Aggregations
For example, you could create a calculated table showing each bicycle model’s total sales by year
Best practices when creating calculated tables
-
Optimize DAX calculations
Complex calculations slow down model performance - Use variables to enhance formula readability. Variables are recommended whenever you have a complex expression.