Forum Discussion
Calculating Quarter over Quarter Change
- 1 year ago
Hi ssrinath ,
Really solid breakdown — and you're absolutely right: built-in functions like PREVIOUSQUARTER() aren't designed for partial period comparisons, especially when you're working at the day level within a quarter.
Here’s a pattern that might help:
Step-by-step approach:
- Create a calculated column in your Date table to shift each date back by 3 months:
PreviousQuarterDate = EDATE('Date'[Date], -3)- Create a measure to get the Volume for the shifted date:
Volume_PrevQ = CALCULATE( [Volume], FILTER( ALL('Date'), 'Date'[Date] = EDATE(SELECTEDVALUE('Date'[Date]), -3) ) )This will give you a day-to-day aligned comparison between the current quarter and the same relative day in the previous quarter.
- Handle quarter-end edge cases\ For the special case where the current date is the last day of the quarter, and the previous quarter had fewer days (e.g., June 30 vs. March 31), you can add logic like:
IsQuarterEnd = 'Date'[Date] = CALCULATE(MAX('Date'[Date]), ALLEXCEPT('Date', 'Date'[Quarter], 'Date'[Year])) AdjustedVolume_PrevQ = IF( [IsQuarterEnd], CALCULATE( [Volume], DATESINPERIOD( 'Date'[Date], EDATE(SELECTEDVALUE('Date'[Date]), -3), -1, DAY ) ), [Volume_PrevQ] )This way, you can aggregate the last few days of the previous quarter only when the current date is the true quarter-end.
Let me know if you want help adapting this to your model — especially if you're using a custom calendar or fiscal quarters.
If my response resolved your query, kindly mark it as the Accepted Solution to assist others. Additionally, I would be grateful for a 'Kudos' if you found my response helpful.
Translation and text formatting supported by AI assistance
Hi ssrinath ,
Really solid breakdown — and you're absolutely right: built-in functions like PREVIOUSQUARTER() aren't designed for partial period comparisons, especially when you're working at the day level within a quarter.
Here’s a pattern that might help:
Step-by-step approach:
- Create a calculated column in your Date table to shift each date back by 3 months:
PreviousQuarterDate = EDATE('Date'[Date], -3)- Create a measure to get the Volume for the shifted date:
Volume_PrevQ =
CALCULATE(
[Volume],
FILTER(
ALL('Date'),
'Date'[Date] = EDATE(SELECTEDVALUE('Date'[Date]), -3)
)
)This will give you a day-to-day aligned comparison between the current quarter and the same relative day in the previous quarter.
- Handle quarter-end edge cases\ For the special case where the current date is the last day of the quarter, and the previous quarter had fewer days (e.g., June 30 vs. March 31), you can add logic like:
IsQuarterEnd =
'Date'[Date] = CALCULATE(MAX('Date'[Date]), ALLEXCEPT('Date', 'Date'[Quarter], 'Date'[Year]))
AdjustedVolume_PrevQ =
IF(
[IsQuarterEnd],
CALCULATE(
[Volume],
DATESINPERIOD(
'Date'[Date],
EDATE(SELECTEDVALUE('Date'[Date]), -3),
-1,
DAY
)
),
[Volume_PrevQ]
)This way, you can aggregate the last few days of the previous quarter only when the current date is the true quarter-end.
Let me know if you want help adapting this to your model — especially if you're using a custom calendar or fiscal quarters.
If my response resolved your query, kindly mark it as the Accepted Solution to assist others. Additionally, I would be grateful for a 'Kudos' if you found my response helpful.
Translation and text formatting supported by AI assistance
- ssrinath1 year agoAdvocate I
Thanks so much for the detailed breakdown!
I should have also mentioned, my date dimension table is limited to the range of my fact table (Fact table min date is 12/01/2021 and max date is 7/02/2025). So when I tried to use the IsQuarterEnd measure as outlined, it returned 7/02/2025.
IsQuarterEnd = 'Date'[Date] = CALCULATE(MAX('Date'[Date]), ALLEXCEPT('Date', 'Date'[Quarter], 'Date'[Year]))Is there any way I can force this to identify that 7/2 is not the real end of the quarter as it should be 9/30 without importing the full 2025 from the date dimension table?