DAX Error: A Function 'CALCULATE' (or 'PLACEHOLDER') Has Been Used in a True/False Expression
This error means a measure, or CALCULATE itself, was used inside one of CALCULATE's filter conditions. A condition like [Total Sales] > 200 can't be a simple filter argument. Here's why, and the two fixes: an explicit FILTER, or a variable.
The error reads either:
A function 'PLACEHOLDER' has been used in a True/False expression that is used as a
table filter expression. This is not allowed.or the same with 'CALCULATE' in place of 'PLACEHOLDER'. It comes from a measure like this:
Big Order Count =
CALCULATE ( COUNTROWS ( Sales ), [Total Sales] > 200 )Why It Happens
CALCULATE accepts two kinds of filter arguments:
- A table, such as
FILTER ( ... ),ALL ( ... ), orVALUES ( ... ). - A condition written as a shortcut, such as
Product[Color] = "Red". DAX expands this into a filter over the column it names:FILTER ( ALL ( Product[Color] ), Product[Color] = "Red" ).
The shortcut only works when DAX can see which column is being filtered and the condition can be tested on that column's values alone. [Total Sales] > 200 names no column: it's a measure, which needs its own filter context to evaluate. There's no column for DAX to build the filter over, so it refuses.
Every measure reference carries a hidden CALCULATE. That's the "function" in the message: when it comes from a measure, Power BI calls it 'PLACEHOLDER'. Write CALCULATE ( SUM ( Sales[Amount] ) ) > 200 and the message names 'CALCULATE' instead. Same rule.
Fix 1: Say Which Rows to Test With FILTER
Decide what you're testing the measure on, and iterate over that with FILTER:
Big Customers Sales =
CALCULATE (
[Total Sales],
FILTER ( VALUES ( Customer[Customer] ), [Total Sales] > 1000 )
)FILTER walks the customers in the current context, evaluates [Total Sales] for each one (each measure reference triggers context transition), and keeps those over 1,000. CALCULATE then uses that list of customers as its filter.
When the test is on a single row's value rather than a measure, test the column directly. To count orders over 200:
Big Order Count =
CALCULATE ( COUNTROWS ( Sales ), FILTER ( Sales, Sales[Amount] > 200 ) )or, since it's a plain column condition, the shortcut form works:
Big Order Count =
CALCULATE ( COUNTROWS ( Sales ), Sales[Amount] > 200 )Fix 2: Compute the Value First With a Variable
When the measure supplies a threshold rather than a per-row test, calculate it once in a variable. A variable is a fixed value by the time CALCULATE sees it, so the shortcut form is allowed again:
Sales Above Average =
VAR AvgOrder = AVERAGE ( Sales[Amount] )
RETURN
CALCULATE ( [Total Sales], Sales[Amount] > AvgOrder )AvgOrder is evaluated in the outer filter context, before CALCULATE changes anything, which is usually what you want for a threshold. See Variables.
What Is Allowed
- Measures and CALCULATE inside FILTER's condition.
FILTER ( VALUES ( Product[Product] ), [Total Sales] > 400 )is normal DAX. - Variables in condition arguments. As in Fix 2.
- Several columns of one table in one condition.
Sales[Region] = "North" || Sales[Product] = "Widget"works, because DAX can build the filter over those columns.
The restriction is narrow: a measure or CALCULATE inside the shortcut condition form of a CALCULATE or CALCULATETABLE filter argument.
Common Mistakes
Wrapping the condition in KEEPFILTERS. It changes how a filter combines with the existing ones, not what a filter argument may contain. The error stays.
Testing the total instead of each row. IF ( [Total Sales] > 200, COUNTROWS ( Sales ) ) saves without error, but tests the total once rather than each order.
Iterating over the whole fact table to test a measure. FILTER ( Sales, [Total Sales] > 200 ) works but triggers a context transition for every row, which is slow on a large table. Iterate over the column you actually mean, such as the customers or products.
Test Yourself
The DAX practice exercises include this exact bug in the Fix the bug group, alongside a dozen other filter context questions.
Next Steps
FAQ
+What does "a function has been used in a True/False expression that is used as a table filter expression" mean?
One of CALCULATE's (or CALCULATETABLE's) filter arguments is a condition like Column = value, and that condition contains a measure or a CALCULATE call. A simple condition filter argument can only test columns against values that don't need their own filter context.
+Why does the error say PLACEHOLDER?
Every measure reference is wrapped in an implicit CALCULATE. When the condition contains a measure, the message names that hidden wrapper as 'PLACEHOLDER'. When you wrote CALCULATE yourself, it names 'CALCULATE'.
+How do I filter CALCULATE by a measure?
Use FILTER over the table or column you want to keep rows from, with the measure in the condition: CALCULATE([Total Sales], FILTER(VALUES(Customer[Customer]), [Total Sales] > 1000)). FILTER evaluates the measure once per row, which a simple condition argument can't do.
+Is CALCULATE allowed inside FILTER?
Yes. FILTER's condition can use measures and CALCULATE freely. The restriction only applies to the simple condition arguments of CALCULATE and CALCULATETABLE.