09.4A measure has no row context

A calculated column knows which row it is on. A measure does not. This difference explains an error that many beginners run into, and this lesson shows how to fix it. If a formula accepted in a calculated column is rejected in a measure, you did not mistype anything, this difference is at play.

09.4.1A bare column in a measure

Let’s try to write the amount as a measure, with the same formula as the Amount column:

rejected in a measureTotal Amount = Sales[Qty] * Sales[Price]

Power BI rejects this measure.

Why? In the calculated column, Sales[Qty] returned the quantity of each row. A measure, on the other hand, is calculated on the visible rows, with no current row.

On the “Total” row of a visual, the 12 sales are visible. Sales[Qty] therefore has 12 values:

The 12 values of Sales[Qty]
The 12 values of Sales[Qty]
V001V002V003V004V005V006V007V008V009V010V011V012
103410683156325

Which one should it take? DAX cannot guess. So Power BI rejects the formula as soon as you write it, even if only one sale were visible, because a measure has no current row. If one of your measures is rejected for this reason, the Diagnostic guides you step by step.

09.4.2Reducing the column to a single value

In a measure, a column must therefore go through a function that reduces its values to a single one, an aggregator like SUM:

Quantity Sold = SUM( Sales[Qty] )
Power BI accepts this DAX foryes, Measureyes, Calculated columnno, Calculated tableno, Virtual table

SUM adds up the 12 quantities and returns a single value, 75. The measure is accepted.

To carry out a calculation row by row in a measure, like the quantity times the price, use an iterator, like SUMX. It places itself on each row, and so creates a row context. Another lesson shows this later.

Quiz

The questions often rely on the course tables. Keep them in view in their floating window, which you can move and enlarge.

Question 1

Which of these measures does Power BI accept?

Question 2

Which of these measures does Power BI reject?

Question 3

A visual has one row per “Sale ID.” Each row therefore leaves only one sale visible. Does the measure Sales[Qty] * Sales[Price] work there?

Key takeaways
  • A measure is calculated on the visible rows, with no current row.
  • In a measure, a bare column is rejected. It goes through a function like SUM, which returns a single value.
  • To calculate row by row in a measure, use an iterator, which creates a row context.