Forum Discussion

AhmadBakr's avatar
AhmadBakr
Icon for Helper IV rankHelper IV
2 years ago
Solved

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...
  • AhmadBakr's avatar
    AhmadBakr
    2 years ago

    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.