1. CALCULATE()
What it is: Alters how data is analyzed.
Why it’s tough: The most fundamental part of almost all DAX formulas and key to flexible row context filtering/modifications.
CALCULATE(SUM(Sales[Revenue]), Region[Country] = "India")
Use case: Benchmark anything against anything programmatically.
2. FILTER()
What it returns: A table that represents a subset of another table or expression.
CALCULATE(SUM(Sales[Revenue]), FILTER(Sales, Sales[Revenue] > 10000))
Use case: When business logic requires advanced filtering beyond slicers.
3. ALL() / ALLEXCEPT()
What it is: A tool cleaner for columns or entire tables.
CALCULATE(SUM(Sales[Revenue]), ALL(Sales))
Use case: Calculating percentages or clearing context filters.
4. RELATED() / RELATEDTABLE()
What it is: Brings in data from associated tables using relationships.
RELATED(Customer[CustomerName])
Use case: Computed fields or measures from joined dimension fields.
5. VAR & RETURN
What it is: Intermediate variables for readable, efficient code.
VAR TotalSales = SUM(Sales[Revenue])
RETURN TotalSales * 0.1
Use case: Step-by-step calculations and debugging.
6. SUMX(), AVERAGEX(), COUNTX()
What it does: Row-by-row operations over a table.
SUMX(Orders, Orders[Quantity] * Orders[Price])
Use case: Custom aggregations, e.g., geo-based averages.
7. RANKX()
What it is: Ranks items based on expression values.
RANKX(ALL(Sales[Product]), SUM(Sales[Revenue]), , DESC)
Use case: Ranking KPIs for products, regions, or employees.
8. EARLIER()
What it does: Returns the previous row context.
CALCULATE(COUNTROWS(Sales), FILTER(Sales, Sales[Date] < EARLIER(Sales[Date])))
Use case: Row-level comparisons, running totals.
9. ISINSCOPE()
What it means: Checks if a column is in the current filter context.
IF(ISINSCOPE(Region[Country]), "Country Level", "All Level")
Use case: Responsive visual titles and KPIs.
10. TREATAS()
Its role: Applies a table expression as a filter on other columns.
CALCULATE(SUM(Sales[Revenue]), TREATAS(VALUES(Customer[Region]), Sales[Region]))
Use case: Creating virtual relationships that filter exist.