DAX language preview
1. Filtered sales measure
CALCULATE with FILTER and column references
horizon-dark
Western Sales =
CALCULATE(
SUM('Sales'[Amount]),
FILTER(ALL('Sales'), 'Sales'[Region] = "West")
) atom-one-dark
Western Sales =
CALCULATE(
SUM('Sales'[Amount]),
FILTER(ALL('Sales'), 'Sales'[Region] = "West")
) github-dark
Western Sales =
CALCULATE(
SUM('Sales'[Amount]),
FILTER(ALL('Sales'), 'Sales'[Region] = "West")
) dracula
Western Sales =
CALCULATE(
SUM('Sales'[Amount]),
FILTER(ALL('Sales'), 'Sales'[Region] = "West")
) nord
Western Sales =
CALCULATE(
SUM('Sales'[Amount]),
FILTER(ALL('Sales'), 'Sales'[Region] = "West")
) github
Western Sales =
CALCULATE(
SUM('Sales'[Amount]),
FILTER(ALL('Sales'), 'Sales'[Region] = "West")
) 2. Year-over-year growth
VAR/RETURN, DIVIDE, and time intelligence
horizon-dark
YoY Growth % =
VAR CurrentSales = SUM('Sales'[Amount])
VAR PriorSales =
CALCULATE(
SUM('Sales'[Amount]),
SAMEPERIODLASTYEAR('Calendar'[Date])
)
RETURN
DIVIDE(CurrentSales - PriorSales, PriorSales, BLANK()) atom-one-dark
YoY Growth % =
VAR CurrentSales = SUM('Sales'[Amount])
VAR PriorSales =
CALCULATE(
SUM('Sales'[Amount]),
SAMEPERIODLASTYEAR('Calendar'[Date])
)
RETURN
DIVIDE(CurrentSales - PriorSales, PriorSales, BLANK()) github-dark
YoY Growth % =
VAR CurrentSales = SUM('Sales'[Amount])
VAR PriorSales =
CALCULATE(
SUM('Sales'[Amount]),
SAMEPERIODLASTYEAR('Calendar'[Date])
)
RETURN
DIVIDE(CurrentSales - PriorSales, PriorSales, BLANK()) dracula
YoY Growth % =
VAR CurrentSales = SUM('Sales'[Amount])
VAR PriorSales =
CALCULATE(
SUM('Sales'[Amount]),
SAMEPERIODLASTYEAR('Calendar'[Date])
)
RETURN
DIVIDE(CurrentSales - PriorSales, PriorSales, BLANK()) nord
YoY Growth % =
VAR CurrentSales = SUM('Sales'[Amount])
VAR PriorSales =
CALCULATE(
SUM('Sales'[Amount]),
SAMEPERIODLASTYEAR('Calendar'[Date])
)
RETURN
DIVIDE(CurrentSales - PriorSales, PriorSales, BLANK()) github
YoY Growth % =
VAR CurrentSales = SUM('Sales'[Amount])
VAR PriorSales =
CALCULATE(
SUM('Sales'[Amount]),
SAMEPERIODLASTYEAR('Calendar'[Date])
)
RETURN
DIVIDE(CurrentSales - PriorSales, PriorSales, BLANK()) 3. Ranked items
RANKX, comments, and column references
horizon-dark
// Rank each item by total sales within its category
Item Rank =
RANKX(
ALLEXCEPT('Inventory', 'Inventory'[Category]),
[Total Sales]
) -- higher amount = better rank atom-one-dark
// Rank each item by total sales within its category
Item Rank =
RANKX(
ALLEXCEPT('Inventory', 'Inventory'[Category]),
[Total Sales]
) -- higher amount = better rank github-dark
// Rank each item by total sales within its category
Item Rank =
RANKX(
ALLEXCEPT('Inventory', 'Inventory'[Category]),
[Total Sales]
) -- higher amount = better rank dracula
// Rank each item by total sales within its category
Item Rank =
RANKX(
ALLEXCEPT('Inventory', 'Inventory'[Category]),
[Total Sales]
) -- higher amount = better rank nord
// Rank each item by total sales within its category
Item Rank =
RANKX(
ALLEXCEPT('Inventory', 'Inventory'[Category]),
[Total Sales]
) -- higher amount = better rank github
// Rank each item by total sales within its category
Item Rank =
RANKX(
ALLEXCEPT('Inventory', 'Inventory'[Category]),
[Total Sales]
) -- higher amount = better rank