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! Learn more

Reply
mfinlay
Advocate II
Advocate II

Prior year calculations based on two dates

Hi Power BI gurus,

I have a measure that has two dates associated with it - a booking date and a shipping date.

I can get prior year calculations easily for one date, using calculate and dateadd DAX, eg for shipping date:

 

mfinlay_1-1632257610901.png

 

 

However, I also want to apply the same filter/calculation to the booking date - ie to effectively see how things are performing at the same point as last year.

 

 Adding a filter on booking date to the table removes the PY numbers, as the PY shipping dates don't have a booking date in the current year:

mfinlay_0-1632257561253.png

Can anyone suggest how I can get the booking date to also go back 364 days, eg to show 434 for Dec-21 in the Transaction Count PY column - which is the total of bookings taken 02/09/2020 - 22/09/2020 with shipping dates 02/12/2020 - 01/01/2021?

 

I've tried applying two filters to the CALCULATE function:

 

 

Transaction count Prior Year - Booking and Shipping Date = 
CALCULATE (
    [Transaction count],
    DATEADD ( 'Shipping Date'[Shipping Date], -364, DAY ),
    DATEADD ( 'Booking Date'[Booking Date], -364, DAY )
)

 

 

 

but this throws an error:

mfinlay_2-1632257740198.png

 

I'm not looking for a complete solution, I'm happy to try and resolve myself if someone could please give me a pointer.

 

PBIX file:

 

https://1drv.ms/u/s!AnNbCRaQC4GBhykaMux22jk4tAy5?e=PS0xjx

 

thanks

Matt

1 ACCEPTED SOLUTION
richbenmintz
Resident Rockstar
Resident Rockstar

Hi @mfinlay ,

 

You can fix your error, by changing your relationship between booking date and data to 1 -> Many and changing to one way.

 

Will review the formula next to try to get the correct result



I hope this helps,
Richard

Did I answer your question? Mark my post as a solution! Kudos Appreciated!

Proud to be a Super User!


View solution in original post

5 REPLIES 5
TheoC
Super User
Super User

Hi @mfinlay 

Create a new measure in your Data table as below. This will ignore any filters from both tables and hopefully give you what you're looking for 🙂

 

Transaction Count (Total CY) =
CALCULATE ( TOTALYTD ( [Transaction count] , Data[Shipping Date] ) , ALL ( 'Booking Date'[Booking Date] ) , ALL ( Data[Booking Date] ) )
 
TheoC_0-1632263715946.png

 

Hope this helps mate!

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

Thanks for your suggestion - I'm afraid I worked from the bottom up and the other reply fixed my issue 🙂

@mfinlay LOL! Mate, too good. Best thing about Power BI is that there's a lot of ways to achieve the outcome you're after.  And I am pretty sure the @richbenmintz approach was much quicker.

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

richbenmintz
Resident Rockstar
Resident Rockstar

Hi @mfinlay ,

 

You can fix your error, by changing your relationship between booking date and data to 1 -> Many and changing to one way.

 

Will review the formula next to try to get the correct result



I hope this helps,
Richard

Did I answer your question? Mark my post as a solution! Kudos Appreciated!

Proud to be a Super User!


Ah, hadn't spotted that the test data had caused an incorrect join.

 

That has fixed my calculation, and the calculation appears to work as I'd hoped - thank you.

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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