Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago

YTD-1

Hello.

I'm having difficulties visualising my YTD for this year and YTD for last year measures.

As you can see from the chart, the YTD-1 goes on until dec 31st, however, I want it to end at the same time as the YTD line. The YTD line stops at the last date with sales numbers. 
The DAX I've used for YTD is :

YTD = var _lastActualValue = MAX(Sheet1[Date])
RETURN
IF(SELECTEDVALUE(Dates[Date])<=_lastActualValue,
CALCULATE(SUM(Sheet1[Verdi]),DATESYTD(Dates[Date]))
)

And for YTD -1 I've used: 
YTD -1 = CALCULATE([YTD],SAMEPERIODLASTYEAR(Dates[Date]))
 
In a table, the output looks like this:
 
Please, any assistance is well appreciated!

 

3 Replies

  • Hi Anonymous 

     

    Try this:

     

    YTD -1 = CALCULATE([YTD],SAMEPERIODLASTYEAR(Dates[Date]),Dates[Date]<=MAX(Sheet1[Date]))
     
    Output=

     

     

    My data:

     

     

    If this post helps, please consider accepting it as the solution to help the other members find it more quickly.

    Appreciate your Kudos!!


    • Anonymous's avatar
      Anonymous
      Not applicable

      Hello VahidDM. Thanks for the tip, however, I'm still unable to make it work.

      Here's how it looks: 


      I have no idea where it's going wrong and it's really frustrating. 

       

      • VahidDM's avatar
        VahidDM
        Icon for Super User rankSuper User

        Hi Anonymous 

         

        Is there any relation between your Date and Value tables? Can you share a sample of your data or share your PBIX file? [after removing sensetive data]

        If this post helps, please consider accepting it as the solution to help the other members find it more quickly.

        Appreciate your Kudos!!