Forum Discussion

ssrinath's avatar
ssrinath
Advocate I
1 year ago
Solved

Calculating Quarter over Quarter Change

Hello,   I have a semantic model with a date dimension table. I also have a fact table from wherw I am calculating a measure called Volume, which is the equivelant of Count (Order ID).   I have a...
  • burakkaragoz's avatar
    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:

    1. Create a calculated column in your Date table to shift each date back by 3 months:
    PreviousQuarterDate = EDATE('Date'[Date], -3)
    1. 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.

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