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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
tonyclifton
Helper III
Helper III

Percentage Calculation of Matrix Total Row

Hello community,

I am trying to get the percentage calculation for the total row of my calculated column "KPI Dev %" right.
The below calculation is correct for each row however for the total row I want to divide the total of KPI DEV by KPI_act.

Background: I have to compare each calendar week to the previous one and calculate the deviation between two weeks.

 

KPI DEV = 
VAR PreviousRow =
    TOPN (
        1,
        FILTER (
            'Table',
              'Table'[CalendarWeek] < EARLIER ('Table'[CalendarWeek]) &&
                 'Table'[YearMonth] = EARLIER ( 'Table'[YearMonth])
                 && 'Table'[Company] = EARLIER ( 'Table'[Company])
        ),
        [CalendarWeek], DESC
    )
VAR PreviousValue =
    MINX ( PreviousRow, [KPI_act] )
RETURN 'Table'[KPI_act] - PreviousValue

 

 

"KPI DEV %" = same as KPI DEV but different return: RETURN CALCULATE(DIVIDE( SUM('Table'[KPI DEV]), PreviousValue))


So in below example for week 38 instead of Sum or Average function over those three rows this is my desired calculation:
Total of (KPI DEV / KPI_act) => 362/22563 = 1,604%

tonyclifton_0-1601047790267.png

Do you have an idea how this can be achieved?

Here's my raw table data:

YearMonthCompanyCalendarWeekKPI_act
01.09.2020 00:00:00Company A3711467
01.09.2020 00:00:00Company A3811697
01.09.2020 00:00:00Company B379607
01.09.2020 00:00:00Company B389742
01.10.2020 00:00:00Company A3711702
01.10.2020 00:00:00Company A3811823
01.10.2020 00:00:00Company B379528
01.10.2020 00:00:00Company B389793
01.09.2020 00:00:00Company C371127
01.09.2020 00:00:00Company C381124
01.10.2020 00:00:00Company C37975
01.10.2020 00:00:00Company C38874


Thank you.

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@tonyclifton, Based on what I have.

For Week-to-Week Better to Create a Week Range on the Start Date of the Week at Week of the Year

Year Week to [Year]*100 + [Week]

Column

Rango de la semana - RANKX (all('Date'),'Date'[Week Start date],,ASC,Dense)

Medida
Esta semana: CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]-max('Date'[Week Rank])))
Last Week ? CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]-max('Date'[Week Rank])-1))

refer to the blog

https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3
https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-La...

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
Icey
Community Support
Community Support

Hi @tonyclifton ,

 

Please refer to this post: Power BI: Totals Incorrect.

 

 

Best Regards,

Icey

 

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

amitchandak
Super User
Super User

@tonyclifton, Based on what I have.

For Week-to-Week Better to Create a Week Range on the Start Date of the Week at Week of the Year

Year Week to [Year]*100 + [Week]

Column

Rango de la semana - RANKX (all('Date'),'Date'[Week Start date],,ASC,Dense)

Medida
Esta semana: CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]-max('Date'[Week Rank])))
Last Week ? CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]-max('Date'[Week Rank])-1))

refer to the blog

https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3
https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-La...

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors