Forum Discussion

Jack007's avatar
Jack007
Frequent Visitor
2 years ago
Solved

How does variable works with the Calculate Function?

I am learning variables in BI.  I want to create a measure that calculates revenue for all years(remove filter context on calendar). I came up with 2 ways to do it.  Method 1. Create a measure call...
  • Alf94's avatar
    2 years ago

    Hi Jack007 ,

     

    Your second measure does not return the expected result because the revenue_calc value is calculated once, and never more. It is calculated when your variable is declared, when the calendar filter context is active. Your variable therefore stores revenues for the selected year. Then, in the "calculate()" part, this value is called directly and not recalculated, so the ALL() function doesn't change anything.

     

    I am not sure my explanations are understandable ๐Ÿ™‚ but you can find the idea in this article.

     

    If I answered your question, please mark my post as a solution.

     

    Best,