Forum Discussion

beanboy's avatar
beanboy
Frequent Visitor
1 year ago
Solved

When to use variables vs measures

Hi everyone, came across some DAX behavior I could use some clarification on. I have some pseudo-code below, but basically I am taking a unique Customers table and counting the rows that meet two con...
  • lbendlin's avatar
    1 year ago

    Measures are dynamic, they recalculate for each different filter context.  You may not always want that, so you materialize intermediate results into variables (which is actually a misnomer as for all intents and purposes these are constants, not variables)  so the values are no longer impacted by subsequent measure calculations.

     

    You can materialize intermediate steps into scalar or table variables but the final result of the measure always must be a scalar value.