Forum Discussion
calculate "around" a variable
- 7 years ago
A variable in DAX is actually a constant. Unlike variables in other programming languages, once you declare a variable in DAX by assigning it a value, that value is immutable. Your variable __TodayVal in the CALCULATE for __PrevVal will not be affected at all by the filter argument.
Thanks MFelix - this makes sense.
Looking at your code and explanation, it still looks like you're not "recalculating" the variable in a different context within the same call, which is what I was trying to accomplish. The solution you provide is very elegant and definitely much more flexible than assuming a continuum of days.
David
Hi dedelman_clng,
When defining the variable and comparing it with the maximum value it can or not recalculate the variable.
If you are using a card it will pick up the full dataset and return the maximum date value so "table context", however when having a table visual you get into the row context of the visual and for each line the maximum value of date is "recalculated" for each interaction of the date.
So it's recalculating in a context enviroment.
Glad I could help.
Regards,
MFelix