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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
StickyFingers78
New Member

Percentages based of subtotals of a matrix

Hello,

 

I am rather new to power BI and i didn't find a answer to what I'm trying to do.

 

Basically I have a matrix with a percentage column that depends on the grand total of a column.

What I'd like to do is that when I expand one level of that matrix, the percentages of the same column, instead of being calculated on the grand total (which look then very small) will now be based on the parent category which was expanded, to sum up to 100.

 

Here is a picture for explanation:

 

StickyFingers78_0-1701423180690.png

I would like the values in the red box to add up to 100% which would be the whole data represented by ZONE3 (which will still stay at 15.26%).

And even better If I can add one level more after to expand which will again add up to 100% then based on my SUBZONE level.

THanks a lot for your help!

2 REPLIES 2
ValtteriN
Super User
Super User

Hi,

Here is one way to do this:

Data:

ValtteriN_0-1701437777561.png

Dax:

Percentage =
var _v = Sum('Table (14)'[Value]) return

SWITCH(TRUE(),

ISFILTERED('Table (14)'[DimC]),_v/CALCULATE(SUM('Table (14)'[Value]),ALL('Table (14)'[DimC])),

ISFILTERED('Table (14)'[DimB]),_v/CALCULATE(SUM('Table (14)'[Value]),ALL('Table (14)'[Dimb])),


 _v/CALCULATE(SUM('Table (14)'[Value]),ALL('Table (14)')))

End result:

ValtteriN_1-1701438645817.png

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/









Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thanks for the answer @ValtteriN ! I think I'm close to the outcome but I still have some issues.

 

Here is a more detailed query 

 

 

%percentage = 
VAR nb_client = SUM(mytable[total_clients_this_year]) RETURN
SWITCH(TRUE(),
ISFILTERED(mytable[ZONE D]), nb_client/CALCULATE(SUM(mytable[total_clients_this_year]), ALL(mytable[ZONE D])),
ISFILTERED(other_table[ZONE C]), nb_client/CALCULATE(SUM(mytable[total_clients_this_year]), ALL(other_table[ZONE C])),
ISFILTERED(other_table[ZONE B]), nb_client/CALCULATE(SUM(mytable[total_clients_this_year]), ALL(other_table[ZONE B])),

 nb_client/CALCULATE(SUM(mytable[YTD]), ALLSELECTED())) --ALL SELECTED because there might be filters on the page to apply here

 

I don't think there should be an issue but you can see that some of the columns i use are from 2 different tables.

What happens is that I get the expected result at the lowest level (zone D) but all other level = 100 % ..

Thanks again !

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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