Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

help on filtering

hi all,

need some advice here on the chart filtering.

i have 3 measure calculated using the filtering

 

next i need to use the above measure to do further % change calculation.

however i got blank, i think it got to do with filtering but doesnt get the correct value.

Can anyone advice? Thank you.

https://gofile.io/?c=xEmO0k

 

 

10 Replies

  • The last 12-months table cal has issues.

    You were able to see data because you have stopped time filter on that visual.

    Please see if this calculation suffices your needs.

     

     

    Last 12 Mths New = 
    VAR _Curr_start = Maxx(dates,DATEADD(STARTOFMONTH(Dates[Date]),-11,MONTH))
    VAR _Curr_END =   Max(Dates[Date])
    Return
    CALCULATE(sum(DATA1[Value]),ALL(DATA1),DATA1[Date]>=_Curr_start && DATA1[Date]<=_Curr_END)

     

    https://www.dropbox.com/s/3svdbxr8akcfctc/filter.pbix?dl=0

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      amitchandak but the values are wrong are the new last 12 mths?

      • amitchandak's avatar
        amitchandak
        Super User

        Calc of 12 month is correct. Currently, the calendar end date is 31-Dec-2019.  So max of that has been taken. Now there two options.

        1. when you have a slicer, it will respond to that. I checked it

        2. Or in the max, you can use the max of sales date.

         

  • v-eachen-msft's avatar
    v-eachen-msft
    Community Support

    Hi Anonymous ,

     

    You can try this measure. 

    Last 12 Mths New =
    VAR _Curr_start =
        MAXX ( DATA1, DATEADD ( STARTOFMONTH ( DATA1[Date1] ), -11, MONTH ) )
    VAR _Curr_END =
        MAX ( DATA1[Date1] )
    RETURN
        SUMX (
            FILTER (
                ALL ( DATA1 ),
                DATA1[Date1] >= _Curr_start
                    && DATA1[Date1] <= _Curr_END
                    && DATA1[Product] = SELECTEDVALUE ( DATA1[Product] )
            ),
            DATA1[Value]
        )

    Here is the result.