10.4CALCULATE cannot filter a variable already calculated

In Excel
ExcelSUMIFS, COUNTIFS or AVERAGEIFS, depending on the calculation
Match

Reusing a variable in another one seems like a good idea, and it often is. Yet here is a case where it gives a wrong result, without any error message. Better to know it before you run into it.

10.4.1A measure that looks perfect

A variable can be used in another variable. Let’s look for the New York share of the revenue. You keep the total revenue in a variable, then you reuse it to calculate the New York revenue:

New York Share = VAR TotalRevenue = SUM( Sales[Amount] ) VAR NewYorkRevenue = CALCULATE( TotalRevenue, Customers[City] = "New York" ) RETURN DIVIDE( NewYorkRevenue, TotalRevenue )
Power BI accepts this DAX foryes, Measureyes, Calculated columnno, Calculated tableno, Virtual table

This measure looks perfect. “TotalRevenue” is reused, no calculation is repeated, and Power BI reports no error.

The rest of this lesson is part of izyDAX Pro

You have just read the first section. The next 3, their animations, the exercises and the summary are waiting for you with izyDAX Pro, in a single payment.