Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
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].

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.

The shortcut

Read any DAX reference by its shape: Table[Column] is a column. [Name] alone is a measure. 'Quoted Name'[Column] is a column in a table whose name has spaces.

Reading Avg Price PaidStep 1 of 4
  1. The name

    Avg Price Paid = means a measure is being defined.

Drills

Answer fast — trust the rule.

quick drill

Which task belongs in M rather than DAX?

quick drill

In Avg Price Paid = DIVIDE ( [Total Revenue], [Total Qty] ), what is [Total Qty]?

quick drill

What does DIVIDE ( 10, 0 ) return?

quick drill

How do you reference the City column in a table named Store List?

quick drill

Over the whole Sales table, what is Avg Price Paid?

Remember

  • M shapes data before it loads; DAX calculates answers after it loads.
  • Read references by shape: Table[Column] is a column, [Name] alone is a measure.
  • Trap: dividing with / where the denominator can be zero or blank — use DIVIDE.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainWhich language, and how to read it

Meera asks why some Leaf & Cup calculations live in Power Query and others in DAX. Explain the difference using splitting the Store column and Pune's share of revenue as examples, and describe how to tell a DAX column reference from a measure reference.