Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Prior Month YTD Issue

I am trying to work with 2 measures: 

Current Month YTD and Prior Month YTD
to have a final result with: 
Current Month = [Current Month YTD]-[Prior Month YTD]
 
I am using the following dax code which works perfect until year 2019:
Current Month YTD = CALCULATE([Total Group Currency], DATEADD(Dates[Date].[Date], 0, MONTH ) )
Prior Month YTD = CALCULATE([Total Group Currency], DATEADD(Dates[Date], -1, MONTH), MONTH(Dates[Date])<>12)
 
But, for some reason my Prior Month YTD calculates one additional month (with no data in current month YTD) and this makes my final result 0:
 
 
 
 
Prior Month YTD should be 19.626.002,68. 
Should anyone has any advice, that really will help me.
 
Thanks
  • Hi Anonymous ,

     

    You can change measure Prior Month YTD using DAX below.

     

    Prior Month YTD = IF([Current Month YTD]=BLANK(),BLANK(),CALCULATE([Total Group Currency], DATEADD(Dates[Date], -1, MONTH), MONTH(Dates[Date])<>12))

     

    Best Regards,

    Amy

     

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

5 Replies

  • v-xicai's avatar
    v-xicai
    Community Support

    Hi Anonymous ,

     

    You can change measure Prior Month YTD using DAX below.

     

    Prior Month YTD = IF([Current Month YTD]=BLANK(),BLANK(),CALCULATE([Total Group Currency], DATEADD(Dates[Date], -1, MONTH), MONTH(Dates[Date])<>12))

     

    Best Regards,

    Amy

     

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

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi, v-xicai 

       

      Thanks for your answer, I'm afraid that my total is still working wrong =(, now I do not see April any more but I'm not sure why the Total sum is still the same as before:

       

       

      Yessi

      • v-xicai's avatar
        v-xicai
        Community Support

        Hi Anonymous ,

         

        Try to refresh , or you can try it again after updating to the latest version of Power BI Desktop 2.68.5432.841.

         

        Best Regards,

        Amy

         

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

    • Anonymous's avatar
      Anonymous
      Not applicable
      It works for me .Thanks.KG