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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Dynamic year on year calculation

Hi all,

 

I am trying to figure out how to calculate a dynamic year on year calculation. I am using the following calculation options:

  • Total Sales SamePeriodLastYear =
    CALCULATE ( [Total Sales], SAMEPERIODLASTYEAR( ( 'Date'[Date] ) ))
    To calculate sales based on a period (month/quarter/year)
  • Total Sales PY =
    CALCULATE ( [Total Sales], DATEADD ( 'Date'[Date], -364, DAY ) )
    To calculate sales based on the same day in the same ISO week (tuesday 08-06-2021 vs tuesday 09-06-2020)

These calculations are indeed dynamic, a user can select a different period by using a slicer which is a dropdown. Here the user can select another year, week or whatever they want. But the problem is that it is always a 1 year comparison.

 

I want to create another dropdown slicer where the user can select a year which then the calculations use for the comparison. So for example:

  • User selects Year 2021 in slicer A which the user wants to see the data from.
  • User selects Year 2017 in slicer B where the comparison will be made. 
  • Result = Year 2021 will be compared with Year 2017 for all measures which uses the above.

I have seen this article which is really usefull and does a bit of what I want to create: Dax Pattersn | Comparing different time periods . But I also want to use the date (year/month/week) on the x axis. Which is not possible with this solution. I have the exact same setup as which is shown in the article.

 

Please could someone help me out with this? If you need more information please let me know.

   

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , In this case, use date month and year from the fact table, instead of date table.

 

Also, if one table is independent and another on is joined, you should be able to use date table

How to use two Date/Period slicers:https://www.youtube.com/watch?v=WSeZr_-MiTg

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi @amitchandak ,

Thanks for your reply. I am sorry but I forgot to mention that, in my fact table, I only use a DateKey which has many to one connection with the Date table.

 

Is it then also possible to use the solutions displayed in the YouTube video? 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors