Forum Discussion

CJANE's avatar
CJANE
Icon for Helper I rankHelper I
5 years ago
Solved

Prior Year to Date - No Date Table

I am trying to create an expression to show total sales for prior YTD.  My Sales and Date are in the same table.  I do not have a separate date table.  Is there an expression that will work for this ...
  • v-cazheng-msft's avatar
    5 years ago

    Hi CJANE 

    You can create a Measure like the following.

     

    LYTD =

    var year=YEAR(MAX(Trades[Trade Date]))-1

    return CALCULATE(SUM(Trades[Gross Amount]), FILTER(ALL(Trades),Trades[Trade Date]>=DATE(year,1,1)&&Trades[Trade Date]<=MAX(Trades[Trade Date])))

     

    The result looks like this:

     

    For more details, you can refer the attached pbix.

     

    Best Regards

    Caiyun Zheng

     

    Is that the answer you're looking for? If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.