Skip to main content
Albero Academy

Introduction to DAX

DAX fundamentals — measures vs calculated columns, CALCULATE, time intelligence, and the patterns analysts use daily.

Chapter 2Power BI18 min readBeginner friendly
  • #Power BI
  • #DAX

DAX (Data Analysis Expressions) is the formula language behind Power BI, Power Pivot, and SSAS Tabular. It looks like Excel, but evaluates against an entire filter context instead of single cells. That difference is everything.

What is DAX?

DAX has 250+ functions. You'll use about 30 of them daily. The mental model:

  • Every visual on the canvas creates a filter context — the slicers, axis values, and column filters in play.
  • A measure is evaluated once per cell in that filter context.
  • To change the filter context, you use CALCULATE.

Measure vs calculated column

AspectCalculated columnMeasure
When evaluatedat refresh timeat query time
Stored inthe model (RAM)computed live
Filter contextrow-levelwhole filter context
Use forstatic row attributesaggregations, KPIs
DAX
-- Measure (preferred)
Total Sales = SUM(Sales[Amount])
Avg Order Value = DIVIDE(SUM(Sales[Amount]), COUNTROWS(Sales))
-- Calculated column (only when needed)
Sales[Margin Bucket] =
SWITCH(
TRUE(),
Sales[Margin] >= 0.30, "High",
Sales[Margin] >= 0.15, "Mid",
"Low"
)

CALCULATE — the workhorse

CALCULATE evaluates an expression in a modified filter context. Almost every non-trivial measure uses it.

CALCULATE patterns
-- Sales for a fixed region
Sales North =
CALCULATE(
[Total Sales],
Region[Name] = "North"
)
-- Sales ignoring the region filter (useful for "% of total")
Sales All Regions =
CALCULATE(
[Total Sales],
REMOVEFILTERS(Region)
)
-- Share of total
Region Share % =
DIVIDE([Total Sales], [Sales All Regions])

Time intelligence

DAX · time intelligence
-- Year-to-date
Sales YTD = TOTALYTD([Total Sales], 'Date'[Date])
-- Same period last year
Sales LY =
CALCULATE([Total Sales], SAMEPERIODLASTYEAR('Date'[Date]))
-- Year-over-year %
YoY % =
DIVIDE([Total Sales] - [Sales LY], [Sales LY])
-- Last 7 days rolling
Sales 7D =
CALCULATE(
[Total Sales],
DATESINPERIOD('Date'[Date], MAX('Date'[Date]), -7, DAY)
)

Iterators (SUMX / AVERAGEX)

X-functions evaluate row-by-row inside the table you give them.

Text
-- Revenue = quantity * price (per row), then summed
Revenue =
SUMX(Sales, Sales[Quantity] * Sales[Price])
-- Average order value, per order — not weighted by line items
AOV =
AVERAGEX(VALUES(Sales[OrderID]), CALCULATE(SUM(Sales[Amount])))

Variables (VAR / RETURN)

Use VAR liberally — it makes complex measures readable and avoids re-computing the same thing twice.

Text
Profit Margin =
VAR Revenue = [Total Sales]
VAR Cost = [Total Cost]
VAR Profit = Revenue - Cost
RETURN
DIVIDE(Profit, Revenue)

Key takeaways

  1. 01DAX evaluates inside a filter context — not against single cells like Excel.
  2. 02Default to measures; use calculated columns only when you need a row attribute.
  3. 03CALCULATE modifies filter context — almost every advanced measure uses it.
  4. 04Time intelligence needs a marked Date table — TOTALYTD, SAMEPERIODLASTYEAR are the workhorses.
  5. 05Iterators (SUMX / AVERAGEX) compute row-by-row inside a table.
  6. 06Always use VAR / RETURN for readable, performant measures.