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
BhavyaM
Helper V
Helper V

How to calculate QOQ change % on year

I have sales column with date column (2019Q1,2019Q2,2019Q3,2019Q4,2020 Q1)

 

Here In Table chart I need to show QoQ change percentage on Year basis like for ex: 

2019Q1 % will be (2020Q1/ 2019Q1)-1

2019Q2 % will be (2020Q1/2019q2)-1

2019Q3 % will be (2020q1/20219q3)-1

 

Please help me how to achieve this

 

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

Hi @BhavyaM ,

 

I create a simple sample. Please reference it to have a try.

 

Calendar =
ADDCOLUMNS (
    CALENDAR ( MIN ( 'Table'[Date] ), MAX ( 'Table'[Date] ) ),
    "Year", YEAR ( [Date] ),
    "Qtr", QUARTER ( [Date] )
)

 

% = 
VAR MaxYear =
    MAX ( 'Calendar'[Year] )
VAR MaxQtr =
    CALCULATE (
        MAX ( 'Table'[Qtr] ),
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Year] = MaxYear )
    )
VAR ThisQtr =
    CALCULATE (
        SUM ( 'Table'[Sales] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Qtr] = MaxQtr && 'Table'[Year] = MaxYear )
    )
VAR LastQtr =
    CALCULATE (
        SUM ( 'Table'[Sales] ),
        FILTER ( 'Table', 'Table'[Year] = MaxYear - 1 )
    )   
RETURN
    DIVIDE ( ThisQtr - LastQtr, LastQtr )

1.PNG

 

For more details, please see the attachment.

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-xuding-msft
Community Support
Community Support

Hi @BhavyaM ,

 

I create a simple sample. Please reference it to have a try.

 

Calendar =
ADDCOLUMNS (
    CALENDAR ( MIN ( 'Table'[Date] ), MAX ( 'Table'[Date] ) ),
    "Year", YEAR ( [Date] ),
    "Qtr", QUARTER ( [Date] )
)

 

% = 
VAR MaxYear =
    MAX ( 'Calendar'[Year] )
VAR MaxQtr =
    CALCULATE (
        MAX ( 'Table'[Qtr] ),
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Year] = MaxYear )
    )
VAR ThisQtr =
    CALCULATE (
        SUM ( 'Table'[Sales] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Qtr] = MaxQtr && 'Table'[Year] = MaxYear )
    )
VAR LastQtr =
    CALCULATE (
        SUM ( 'Table'[Sales] ),
        FILTER ( 'Table', 'Table'[Year] = MaxYear - 1 )
    )   
RETURN
    DIVIDE ( ThisQtr - LastQtr, LastQtr )

1.PNG

 

For more details, please see the attachment.

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
mahoneypat
Employee
Employee

Do you have a Date table in your model?  If so, you can make a column that has the same YearQuarter syntax and have a relationship to your existing YearQuarter column, and you could use Time Intelligence DAX to do you calculatation.  If not, you could add a column in the query editor (or with DAX as a calculated column) that has the last date of each quarter.  Then you can write DAX expressions with variables to get the current value and previous quarter value, and do you calculation to get the QoQ change.


If you are not familiar with how to do that, you can post some sample/mock data and the community will likely respond with the exact formula you need.

 

If this works for you, please mark it as solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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