Forum Discussion

MischaT's avatar
MischaT
Frequent Visitor
3 years ago
Solved

DATESYTD Issue (Rolling Cumulation)

H there! 

 

I am having an issue with one of my rolling calculations for the below table:

  Number of Apples soldYTD Apples sold (rolling)Shop SalesApple + Shop Sales

YTD Apple + Shop Sales (Rolling)

 

(Calculating incorrectly)

Expected outcome
2022January000000
2022February000000
2022March180018000180001800
2022April0180023000250502300026850
2022May817958384508384523000110695
2022June08384595000179095118250289790
2022July475088845088845118250378635
2022August088845104550193645223050572280
2022September08884526900115995250200688275

 

The current Dax for "YTD Apple + Shop Sales (Rolling)" is 

YYTD Apple + Shop Sales (Rolling)= CALCULATE([Apple + Shop Sales],DATESYTD('Table'[Date],"28/02"))
and is not calculating correctly (I have included an expected value)
 
Please help!
The measure for "YTD Apples sold (rolling)" is similar:
YTD Apples sold (rolling) = CALCULATE(Number of Apples sold],DATESYTD('Table'[Date],"28/02"))
but it works correctly. 
 
Any suggestions?
Thanks as always!
  • Hi,

    You can simplyfy the DAX a bit:

    IF(

        isblank([Shops calc]),
        0,
        [Shops calc])

    Then create a YTD calculation for this measure and just [YTD Apples sold (rolling)]+[Shop Sales (rolling)]. [Since Apple + Shop Sales]] already has YTD calculation within it it isn't necessary to calculate it again for the [YTD Apples sold (rolling)] part. 

    In short create separate YTD calculations and + these together.

    I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

    My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/

4 Replies

  • ValtteriN's avatar
    ValtteriN
    Icon for Community Champion rankCommunity Champion

    Hi,

    What kind of calculation are you using in your [Apple + Shop Sales]? The issue is with DATESYTD interaction with this measure so that dax should be revised.

    • MischaT's avatar
      MischaT
      Frequent Visitor

      Hello! 

       

      Thank you for your response

       

      Please see below:

      Apple + Shop Sales = CALCULATE([YTD Apples sold (rolling)]+[Shop Sales])

      And Shop sales are calculated by two measures:

      1. Shops calc = CALCULATE( SUM(Shop[ShopNum]),Shop[ShopName]="Shop Sales")
       
      and
       
      Shop Sales = IF(
          [Shops calc]=BLANK(),
          0,
          CALCULATE([Shops calc]))
      • ValtteriN's avatar
        ValtteriN
        Icon for Community Champion rankCommunity Champion

        Hi,

        You can simplyfy the DAX a bit:

        IF(

            isblank([Shops calc]),
            0,
            [Shops calc])

        Then create a YTD calculation for this measure and just [YTD Apples sold (rolling)]+[Shop Sales (rolling)]. [Since Apple + Shop Sales]] already has YTD calculation within it it isn't necessary to calculate it again for the [YTD Apples sold (rolling)] part. 

        In short create separate YTD calculations and + these together.

        I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

        My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/