# DAX and Calculated Measures

> Writing measures in DAX: filter context, CALCULATE, iterators and time intelligence, the skill that separates Power BI users from builders. Free notes, key...

Canonical: https://www.internhack.in/roadmaps/tracks/data-analyst/dax-measures
Last updated: 2026-11-28

Writing measures in DAX: filter context, CALCULATE, iterators and time intelligence, the skill that separates Power BI users from builders.

Intermediate · about 12 hours · difficulty 4/5

Learn first: [Power BI](https://www.internhack.in/roadmaps/tracks/data-analyst/power-bi)

DAX (Data Analysis Expressions) is the formula language of Power BI, Excel Power Pivot and Analysis Services. It looks like Excel formulas but behaves very differently, because every measure is evaluated inside a **filter context** set by the visual.

### The two contexts

- **Filter context**: the filters coming from rows, columns, slicers and relationships. A `Total Sales := SUM(Sales[Amount])` measure shows a different number in every cell because each cell has a different filter context.
- **Row context**: exists inside calculated columns and iterator functions, meaning "the current row".

### CALCULATE is the key

`CALCULATE(expression, filters...)` evaluates an expression under modified filters. Examples:

- `Sales LY := CALCULATE([Total Sales], SAMEPERIODLASTYEAR('Date'[Date]))`
- `Sales All Regions := CALCULATE([Total Sales], REMOVEFILTERS(Region))` for percent of total.

### Other essentials

- **Iterators** such as `SUMX(Sales, Sales[Qty] * Sales[Price])` compute row by row, then aggregate.
- **DIVIDE** handles divide-by-zero safely.
- **Variables** (`VAR ... RETURN`) make long measures readable and faster.
- **Time intelligence** (TOTALYTD, DATEADD) needs a proper, marked date table.

**Pitfall:** creating calculated columns for things that should be measures, bloating the model and giving wrong totals. Prefer measures unless you need to slice by the value. You are ready to move on when you can write year-over-year growth, percent of total and a rolling 3-month average as measures and explain their filter context.

## Key concepts

- **Measures vs calculated columns**
- **Filter context and row context**
- **CALCULATE and filter modifiers**
- **Iterators: SUMX, AVERAGEX**
- **Time intelligence functions**
- **Variables in DAX**
- **Context transition**: Why a measure inside an iterator behaves differently
- **Performance Analyzer and DAX Studio**

## Mini project

In your Power BI report add measures for YoY growth %, percent of category total, rolling 3-month sales and customer count with at least two orders, each documented with a one-line description.

## Check yourself

Explain in plain words why the same SUM measure returns different numbers in each cell of a matrix.

## Free resources

- [DAX reference](https://learn.microsoft.com/en-us/dax/) (Microsoft)
- [DAX overview in Power BI](https://learn.microsoft.com/en-us/dax/dax-overview) (Microsoft)
- [DAX Guide](https://dax.guide/) (SQLBI)

Previous: [Metabase](https://www.internhack.in/roadmaps/tracks/data-analyst/metabase) · Next: [Publishing, Security and BI Governance](https://www.internhack.in/roadmaps/tracks/data-analyst/bi-governance)

## More in Business Intelligence Tools

- [How BI Platforms Work](https://www.internhack.in/roadmaps/tracks/data-analyst/bi-concepts)
- [Power BI](https://www.internhack.in/roadmaps/tracks/data-analyst/power-bi)
- [Tableau](https://www.internhack.in/roadmaps/tracks/data-analyst/tableau)
- [Looker Studio](https://www.internhack.in/roadmaps/tracks/data-analyst/looker-studio)
- [Metabase](https://www.internhack.in/roadmaps/tracks/data-analyst/metabase)
- [DAX and Calculated Measures](https://www.internhack.in/roadmaps/tracks/data-analyst/dax-measures)
- [Publishing, Security and BI Governance](https://www.internhack.in/roadmaps/tracks/data-analyst/bi-governance)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Data Analyst Roadmap](https://www.internhack.in/roadmaps/tracks/data-analyst)
