Skip to the workspace
Pebellslearn by building
DAX Fundamentals  ›  Lesson

DAX vs M, and DAX Syntax

DAX Syntax 12 minM shapes data in Power Query before it loads, while DAX calculates answers over the loaded model, with columns written as Table[Column] and measures as [Measure].

power bi / DAX vs M, and DAX Syntax

Explore each scene at your own pace.

01 · The rule

The rule

DAX vs M, and DAX Syntax

Everything Arjun has written so far is M: it runs at refresh and shapes the data on its way in. Now Meera asks, "What share of revenue came from Pune — and from whichever dates I pick?" That answer depends on what she has selected on the page at the moment she looks. Questions like that are the job of Power BI's second language, DAX (Data Analysis Expressions).

The rule

M shapes data before it loads; DAX calculates answers after it loads.

M (Power Query) DAX
Runs At refresh In the model: measures whenever a visual asks; calculated columns at refresh
Works on One query at a time, step by step Loaded tables and their relationships, under the page's filters
Typical jobs Clean, type, split, merge, append Totals, ratios, comparisons, time calculations
Looks like let … in with steps Excel-style formulas
Case Case-sensitive Function names are not case-sensitive

A useful split: if a value belongs to a row and never changes with what is selected, shape it in M. If it depends on slicers, filters and the visual it sits in, write it in DAX.

A DAX measure looks like this:

Total Revenue = SUM ( Sales[Line Revenue] )
Total Qty = SUM ( Sales[Qty] )
Avg Price Paid = DIVIDE ( [Total Revenue], [Total Qty] )

Reading the parts:

  • Total Qty = names the measure. Names may contain spaces.
  • SUM ( … ) is a function; arguments go inside parentheses, separated by commas.
  • Sales[Qty] is a column: the table name, then the column name in square brackets. If a table name contains spaces, wrap it in single quotes: 'Store List'[City].
  • [Total Revenue] on its own is a measure reference. Measures are written without a table name, so you can tell them from columns at a glance.
  • Operators: + - * / for arithmetic, & joins text, && means and, and comparisons are = <> > >= < <=.
  • DIVIDE ( a, b ) is safe division: when b is 0 or blank it returns BLANK, where plain a / b would give infinity or a not-a-number result.
  • // starts a comment.

Over all six January orders, Total Revenue is 600, Total Qty is 20, and Avg Price Paid is 600 / 20 = 30.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.