Forum Discussion

GuiBrum's avatar
GuiBrum
Frequent Visitor
6 years ago
Solved

Sales Past Years to Date

Hello, I'm trying to set up a measure to show me the previous years sales to date. tblSales: [Inv Date], [Inv Amount]   Year     YTD Sales Amount 2016    4,000 2017    4,500 2018    4,800     ...
  • Anonymous's avatar
    Anonymous
    6 years ago

    GuiBrum 

     

    Did you related the two table with columns Date[Date] and tblSales[Inv Date]? I guess you can filter with the [Inv Date] in the sales table instead of change the code to Date[Date], try stick it with the first filter. And you may replace Today() with 2020.05.20 to test.

     

    Measure = Calculate( sum([Inv Amount]),FILTER(ALL(tblSales),[Inv Date]<=MAX([Inv Date])),
    FILTER(ALL(tblSales),
    SUMX(FILTER(tblSales,
        EARLIER(tblSales[Inv Date].[Year])=[Inv Date].[Year]
    &&  EARLIER(tblSales[Inv Date].[MonthNo])<=MONTH(DATE(2020,5,20))
    &&  EARLIER(tblSales[Inv Date].[Day])<=DAY(DATE(2020,5,20))),1)))

     

     

    Could you provide a sample pbix if it still goes wrong

     

    Paul Zheng _ Community Support Team
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.