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

% change between previous and current quarters in power bi

can you please assist on how do i calculate the % change between previous and current quarters in power bi 

 

1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

HI @Anonymous,

You can use year and quarter functions to extract the year and quarter numbers from the date field value, then you can use them in expression to get corresponding current and previous quarter values to calculate the diff.

formual =
VAR currDate =
    MAX ( Table[Date] )
VAR prevDate =
    DATE ( YEAR ( currDate ), MONTH ( currDate ) - 3, DAY ( currDate ) )
VAR currQuarter =
    CALCULATE (
        SUM ( Table[Amount] ),
        FILTER (
            ALLSELECTED ( Table ),
            YEAR ( Table[Date] ) = YEAR ( currDate )
                && QUARTER ( Table[Date] ) = QUARTER ( currDate )
        ),
        VALUES ( Table[Category] )
    )
VAR prevQuarter =
    CALCULATE (
        SUM ( Table[Amount] ),
        FILTER (
            ALLSELECTED ( Table ),
            YEAR ( Table[Date] ) = YEAR ( prevDate )
                && QUARTER ( Table[Date] ) = QUARTER ( prevDate )
        ),
        VALUES ( Table[Category] )
    )
RETURN
    DIVIDE ( currQuarter - prevQuarter, prevQuarter )

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

2 REPLIES 2
v-shex-msft
Community Support
Community Support

HI @Anonymous,

You can use year and quarter functions to extract the year and quarter numbers from the date field value, then you can use them in expression to get corresponding current and previous quarter values to calculate the diff.

formual =
VAR currDate =
    MAX ( Table[Date] )
VAR prevDate =
    DATE ( YEAR ( currDate ), MONTH ( currDate ) - 3, DAY ( currDate ) )
VAR currQuarter =
    CALCULATE (
        SUM ( Table[Amount] ),
        FILTER (
            ALLSELECTED ( Table ),
            YEAR ( Table[Date] ) = YEAR ( currDate )
                && QUARTER ( Table[Date] ) = QUARTER ( currDate )
        ),
        VALUES ( Table[Category] )
    )
VAR prevQuarter =
    CALCULATE (
        SUM ( Table[Amount] ),
        FILTER (
            ALLSELECTED ( Table ),
            YEAR ( Table[Date] ) = YEAR ( prevDate )
                && QUARTER ( Table[Date] ) = QUARTER ( prevDate )
        ),
        VALUES ( Table[Category] )
    )
RETURN
    DIVIDE ( currQuarter - prevQuarter, prevQuarter )

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
SpartaBI
Community Champion
Community Champion

@Anonymous read this full article:
https://www.daxpatterns.com/standard-time-related-calculations/
You also have there a section about quarter over quarter.



2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png


Full-Logo11.png

SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Showcase Report – Contoso By SpartaBI

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

April Fabric Community Update

Fabric Community Update - April 2024

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

March 2024 PBI Gallery Image

Power BI Monthly Update - March 2024

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

Top Solution Authors