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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
derekli17001
Helper I
Helper I

How to fix my percentage increase/decrease for month on month returns?

1.png  

2..PNG

 

 This is my current matrix where it shows the sales (cards) from 2020- 2024. The YOY percentages seem fine but when you drill down by month, the percentages month by month compare the difference from previous year rather than reflect the difference from last month. Eg) as seen in pic 2 , December 2021 says 11.95% because thats the improvement from December 2020. However, i want the percentage next to December 2021 to reflect the increase/decrease from November 2021.

 

These are my current measures in place: (note a date table is already included)

C% =
VAR CurrentYearCards =
    SUM ( 'Table'[Cards] )
VAR PreviousCards =
    CALCULATE ( SUM ( 'Table'[Cards] ), DATEADD ( 'Date'[Date], -1, YEAR ) )
RETURN
    DIVIDE ( CurrentYearCards - PreviousYearCards, PreviousYearCards, 0 )

Min Year = CALCULATE(sum('Table'[Cards]),filter(ALL('Date'),'Date'[Year]=Minx(allselected('Date'),'Date'[Year])))


Max Year = CALCULATE(sum('Table'[Cards]),filter(ALL('Date'),'Date'[Year]=Maxx(allselected('Date'),'Date'[Year])))


Final % = if(isinscope('Date'[Year]), [C%], divide([Max Year]-[Min Year ],[Min Year ]))

 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I am not 100% sure if I understood your question correctly, but please try something like below whether it suits your requirement.

 

C% =
VAR CurrentYearCards =
    SUM ( 'Table'[Cards] )
VAR PreviousYearCards =
    CALCULATE ( SUM ( 'Table'[Cards] ), DATEADD ( 'Date'[Date], -1, YEAR ) )
VAR PreviousMonthCards =
    CALCULATE ( SUM ( 'Table'[Cards] ), DATEADD ( 'Date'[Date], -1, MONTH ) )
RETURN
    SWITCH (
        TRUE (),
        ISINSCOPE ( 'Date'[Month] ), DIVIDE ( CurrentYearCards - PreviousMonthCards, PreviousMonthCards, 0 ),
        ISINSCOPE ( 'Date'[Year] ), DIVIDE ( CurrentYearCards - PreviousYearCards, PreviousYearCards, 0 )
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

View solution in original post

5 REPLIES 5
Jihwan_Kim
Super User
Super User

Hi,

I am not 100% sure if I understood your question correctly, but please try something like below whether it suits your requirement.

 

C% =
VAR CurrentYearCards =
    SUM ( 'Table'[Cards] )
VAR PreviousYearCards =
    CALCULATE ( SUM ( 'Table'[Cards] ), DATEADD ( 'Date'[Date], -1, YEAR ) )
VAR PreviousMonthCards =
    CALCULATE ( SUM ( 'Table'[Cards] ), DATEADD ( 'Date'[Date], -1, MONTH ) )
RETURN
    SWITCH (
        TRUE (),
        ISINSCOPE ( 'Date'[Month] ), DIVIDE ( CurrentYearCards - PreviousMonthCards, PreviousMonthCards, 0 ),
        ISINSCOPE ( 'Date'[Year] ), DIVIDE ( CurrentYearCards - PreviousYearCards, PreviousYearCards, 0 )
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

That was perfect, thanks. Your measure makes the bottom slot (highlighted in pic) blank - so i was wondering if theres a way to have a figure there that calculates the difference from 2024 to 2020? Thanks!

derekli17001_0-1724214960072.png

 

Hi,

I do not know how your semantic model looks like, but please try something like below.

 

C% =
VAR CurrentYearCards =
    SUM ( 'Table'[Cards] )
VAR PreviousYearCards =
    CALCULATE ( SUM ( 'Table'[Cards] ), DATEADD ( 'Date'[Date], -1, YEAR ) )
VAR PreviousMonthCards =
    CALCULATE ( SUM ( 'Table'[Cards] ), DATEADD ( 'Date'[Date], -1, MONTH ) )
VAR _startingyear =
    MINX ( SUMMARIZE ( 'Table', 'Date'[Year] ), 'Date'[Year] )
VAR _latestyear =
    MAXX ( SUMMARIZE ( 'Table', 'Date'[Year] ), 'Date'[Year] )
VAR _startingyearcards =
    CALCULATE ( SUM ( 'Table'[Cards] ), 'Date'[Year] = _startingyear )
VAR _latestyearcard =
    CALCULATE ( SUM ( 'Table'[Cards] ), 'Date'[Year] = _latestyear )
RETURN
    SWITCH (
        TRUE (),
        ISINSCOPE ( 'Date'[Month] ), DIVIDE ( CurrentYearCards - PreviousMonthCards, PreviousMonthCards, 0 ),
        ISINSCOPE ( 'Date'[Year] ), DIVIDE ( CurrentYearCards - PreviousYearCards, PreviousYearCards, 0 ),
        DIVIDE ( _latestyearcard - _startingyearcards, _startingyearcards, 0 )
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Hello,

 

Thank you and apologies

 

Here is my report Sample.pbix

Your calculation has fixed the month by month percentage difference however i noticed the YOY difference seems to be wrong.

derekli17001_0-1724306671628.png

As seen in the picture, 2024 seems to be less than 2023 however it shows a posititve increase of 16.68%. Any guidance will help - many thanks!

Jihwan_Kim_0-1724310247215.png

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.