Forum Discussion

FelipeGualberto's avatar
FelipeGualberto
Frequent Visitor
8 years ago
Solved

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...
  • Phil_Seamark's avatar
    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 )
            )