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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Fabric Monthly Update - May 2024

Check out the May 2024 Fabric update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors