Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
AhmadBakr
Advocate II
Advocate II

Defining a measure using another measure vs. using a var carrying the value of that measure

Why the below measure is giving me the error:

"A function 'PLACEHOLDER' has been used in a True/False expression that is used as a table filter expression. This is not allowed."

 

chk RunWD =
VAR fdt = [chk FDate]
VAR Result =

CALCULATE(
COUNTROWS(DimWDates),
DimWDates[Date] > [chk FDate],      --> returned error!
DimWDates[Date] <= TODAY()
)

RETURN Result

 

While the below is working fine, although they look the same!!! Just defined the measure as a variable!

 

chk RunWD =
VAR fdt = [chk FDate]
VAR Result =

CALCULATE(
COUNTROWS(DimWDates),
DimWDates[Date] > fdt,                 --> worked fine!!!
DimWDates[Date] <= TODAY()
)

RETURN Result

1 ACCEPTED SOLUTION

Hey @Greg_Deckler , thank you for your response.

I was thinking of the same approach, in fact 🙂.

 

It worked! no errors ✔️✔️✔️, same as defining a VAR.

 

However, this still does not answer the question: Why using the measure directly in the calculate filter argument returns an error!

 

I tried checking chatgpt and it gave me a strange explanation:

"In the first case, [chk FDate] is a measure and is directly used in the filter expressions. When you use a measure directly inside a CALCULATE filter argument, DAX expects it to be a valid True/False expression. However, measures often return scalar values rather than Boolean values, causing this error.

 

While in the second, the value of [chk FDate] is first stored in the variable fdt. Since fdt is now a scalar value (the result of the measure [chk FDate]), it can be safely used in the CALCULATE function as part of the filter expressions.

 

When you assign the result of a measure to a variable, you’re effectively converting the measure into a constant value that DAX can use as part of a logical comparison. Without this step, DAX tries to interpret the measure itself as a condition, which leads to the error."

 

chatgpt's answer means that DAX did not interpret the value of the measure, which is weird - if true.

View solution in original post

2 REPLIES 2
Greg_Deckler
Community Champion
Community Champion

@AhmadBakr Probably has something to do with CALCULATE and measures in filter clauses. What does this do?

chk RunWD =
VAR fdt = [chk FDate]
VAR Result = COUNTROWS( FILTER( 'DimWDates', [Date] > [chk FDate] && [Date] <= TODAY() ) )
RETURN
Result


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hey @Greg_Deckler , thank you for your response.

I was thinking of the same approach, in fact 🙂.

 

It worked! no errors ✔️✔️✔️, same as defining a VAR.

 

However, this still does not answer the question: Why using the measure directly in the calculate filter argument returns an error!

 

I tried checking chatgpt and it gave me a strange explanation:

"In the first case, [chk FDate] is a measure and is directly used in the filter expressions. When you use a measure directly inside a CALCULATE filter argument, DAX expects it to be a valid True/False expression. However, measures often return scalar values rather than Boolean values, causing this error.

 

While in the second, the value of [chk FDate] is first stored in the variable fdt. Since fdt is now a scalar value (the result of the measure [chk FDate]), it can be safely used in the CALCULATE function as part of the filter expressions.

 

When you assign the result of a measure to a variable, you’re effectively converting the measure into a constant value that DAX can use as part of a logical comparison. Without this step, DAX tries to interpret the measure itself as a condition, which leads to the error."

 

chatgpt's answer means that DAX did not interpret the value of the measure, which is weird - if true.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.