Forum Discussion
FelipeGualberto
8 years agoFrequent Visitor
SELECTEDVALUE doesn't work indirectly
Hello, When I use this measure: Sales Selected Year = CALCULATE(SUM(fSales[Value]), FILTER(ALL(dCalendar), dCalendar[Year] = SELECTEDVALUE(dCalendar[Year])) It brings all sales from 2018 (co...
- 8 years ago
Welcome to the fun world of DAX filter context.
The CALCULATE function is quite magical in the way it can create a new filter context for the expression to work with.
If you would like your calculation to work the way you want, please try this.
Sales Selected Year = VAR x = [Selected Year] RETURN CALCULATE( SUM(fSales[Value]), FILTER(ALL(dCalendar), dCalendar[Year] = x ) )
Phil_Seamark
Microsoft Employee
8 years agoWelcome to the fun world of DAX filter context.
The CALCULATE function is quite magical in the way it can create a new filter context for the expression to work with.
If you would like your calculation to work the way you want, please try this.
Sales Selected Year =
VAR x = [Selected Year]
RETURN
CALCULATE(
SUM(fSales[Value]),
FILTER(ALL(dCalendar), dCalendar[Year] = x )
)- FelipeGualberto8 years agoFrequent Visitor
Thanks, Phil!
Strangely enough, the calculation is working now in both methods in another computer.
But it is very good to learn this technique, so now I know that sometimes I have to access a measure indirectly using a variable.
Have a good day!