Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Year-over-Year Running Total

Hi,

 

I have a sales table that I am looking to create a measure for that calculates the percentage change year-over-year. Simple enough, but for the year 2021 the percentage is way off because we have only experienced the month of January. So for 2021 I want the measure to calculate the percentage change of the running total from 2020 (January only) compared to the running total of 2021 (January only).  

 

See picture below, instead of -97.25% I'd like the percentage to be the difference between 2021 sales and 2020 sales up until the point 2021 is up to (January in this case), so the percentages are much more comparable.

 

The current measure I have is:

 
Sales YoY% =
VAR __PREV_YEAR = CALCULATE(SUM('Example'[Sales]), DATEADD('Dates'[Date], -1, YEAR))
RETURN
    DIVIDE(SUM('Example'[Sales]) - __PREV_YEAR, __PREV_YEAR) 

 

 

  • Hi, Anonymous 

    How did you create the 'Dates' table? Please check your maximum date in the 'Date'' table.

    You need a calendar table to return  all dates between January 1, 2018 and  current max date.

    Please try to create a calculated table as below:

     

    Dates1 = CALENDAR(MIN(Example[Date]),MAX(Example[Date]))

     

     

    And  it isn't recommended to use  function 'CALENDARAUTO()' to create a calendar table here.

    It will generate a table that returns all dates between January 1, 2018 and December 31, 2021.


    test result using Calendarauto:

    Please check my test file for more details.

     

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

5 Replies

  • Anonymous use parallel period DAX function

     

    Check my latest blog post Compare Budgeted Scenarios vs. Actuals I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

    Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.

     

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you for the response. I tried that function but it did not work because I need a timeframe of up until today's date last year, not a general year, quarter or month time frame.

       

      I've gotten the measure to this to change the measure if the selected year is the current one. Do you know how I might replace "missing calc" to sum up last year's sales up until today's date last year (so in this case, 1/22/2020)?:

       

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

        Hi,

        Try this measure

        =calculate([Spend (Focused Accounts)],datesbetween('Dates'[Date],date(year(today())-1,1,1),edate(today(),-12)))

        Hope this helps.

  • v-easonf-msft's avatar
    v-easonf-msft
    Icon for Community Support rankCommunity Support

    Hi, Anonymous 

    How did you create the 'Dates' table? Please check your maximum date in the 'Date'' table.

    You need a calendar table to return  all dates between January 1, 2018 and  current max date.

    Please try to create a calculated table as below:

     

    Dates1 = CALENDAR(MIN(Example[Date]),MAX(Example[Date]))

     

     

    And  it isn't recommended to use  function 'CALENDARAUTO()' to create a calendar table here.

    It will generate a table that returns all dates between January 1, 2018 and December 31, 2021.


    test result using Calendarauto:

    Please check my test file for more details.

     

    Best Regards,
    Community Support Team _ Eason
    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

      thank you so much!