Forum Discussion

Phoenix538's avatar
Phoenix538
Frequent Visitor
6 years ago
Solved

Use selected filter for previous year

Good day all, I am pretty new to Power Bi, loveing the program but stumbling accross something that I cannot figure out.   I sccuesfully managed to calculate the YTD turnover and compare it to the...
  • V-lianl-msft's avatar
    6 years ago

    Hi Phoenix538 ,

     

    You can try to create an unrelated calendar table to use as a slicer.

    Running total:

    Running total= 
    CALCULATE (
        SUM ( Sales[Sales] ),
        FILTER (
            ALLSELECTED ( 'Sales' ),
           SELECTEDVALUE(DimDate[year])= YEAR(Sales[Date])&&
           Sales[Date]<=MAX(Sales[Date])
        )
    )

    Sum of last year:

    sum_Sales_last_year = 
    CALCULATE (
        SUM( Sales[Sales] ),
        FILTER (
            ALL ( Sales[Date] ),
            YEAR(Sales[Date]) = SELECTEDVALUE(DimDate[year])-1
         ))

    Sample .pbix

     

    Best Regards,
    Liang
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.