Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

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) 

 

example.PNG

 

1 ACCEPTED SOLUTION
v-easonf-msft
Community Support
Community 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]))

 

33.png

 

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:
32.png

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.

View solution in original post

5 REPLIES 5
v-easonf-msft
Community Support
Community 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]))

 

33.png

 

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:
32.png

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
Not applicable

thank you so much!

parry2k
Super User
Super User

@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.

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

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)?:

 

Hi,

Try this measure

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

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.