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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Data_BS
New Member

Percentage of grand total problem

Hi community, 


I am trying to calculate the % of a grand total for a dimension column but with a slight twist. If a category's % of grand total is less than or equal to 10%, I'd like to bundle these categories into a group called "other" and the grand total of the "other" group should be the sum of their grand total %s.

I'd like the solution to be dynamic. For instance, I could select swap out different dimensions in a visual and this solution would work. Below is an example of what I'm trying to achieve. If anything is unclear, please shout. I'm open to any solution.

 

Example Data

Screenshot 2024-10-15 085920.png

Expected Output
Note, I've supplied two different tables in the solution. In PBI, I'd like just one table with the ability to pull the different dimensions into it.


Screenshot 2024-10-15 090435.png

 

Data used in problem

 

CountryFavourite ColourFlag
UKRed1
USARed1
FranceRed1
UKBlue1
UKBlack1
UKWhite1
GermanyGreen1
GermanyGreen1
GermanyBlue1
GermanyPink1

 

Thanks,

Ben

1 ACCEPTED SOLUTION
SamWiseOwl
Super User
Super User

Hi @Data_BS 

You need to Append a new row to the table with "Other" in both the country and the colour columns.

This is used to check which row we are on in the visual.

SamWiseOwl_0-1728984362289.png

Field Parameters: https://learn.microsoft.com/en-us/power-bi/create-reports/power-bi-field-parameters

Let you swap which column is in the visual.

Create a measure:

Sales =
 var curr = CALCULATE(sum('Table'[Flag]))
 var total = CALCULATE(sum('Table'[Flag]),REMOVEFILTERS('Table'[Country],'Table'[Favourite Colour]))
 var per = curr/total
var sel = MAXX('Choose category',[Choose category])
 var colour = SUMMARIZE(ALLSELECTED('Table'),'Table'[Favourite Colour], "Percent",
  CALCULATE(sum('Table'[Flag]))/CALCULATE(sum('Table'[Flag]),REMOVEFILTERS('Table'[Country],'Table'[Favourite Colour])))
  var country = SUMMARIZE(ALLSELECTED('Table'),'Table'[Country], "Percent"
 ,CALCULATE(sum('Table'[Flag]))/CALCULATE(sum('Table'[Flag]),REMOVEFILTERS('Table'[Country],'Table'[Favourite Colour])))


var final =
SWITCH(
    TRUE()
    ,sel = "Country" && SELECTEDVALUE('Table'[Country]) = "Other"
    ,sumx(filter(country, [Percent] <=0.1), [Percent])
    ,SELECTEDVALUE('Table'[Favourite Colour]) = "Other"
    ,sumx(filter(colour, [Percent] <=0.1), [Percent])
    ,per <= 0.1
    ,BLANK()
    ,per)
return final
   
This tests if the selected item is Colour or Category, calculates which rows are below 10% and returns the appropriate calculation.
Hope this helps!
 

If you are happy with this answer please mark as a solution for others to find !

Kudos are always appreciated! Check out our free Power BI video courses.

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi @Data_BS , hello ryan_mayu and SamWiseOwl, thank you for your prompt reply!

Is there any progress on this issue?

 

If you find any answer is helpful to you, please remember to accept it.

 

It will help others who meet the similar question in this forum.

 

Thank you for your understanding.

ryan_mayu
Super User
Super User

@Data_BS 

 

have you tried grouping and binning function?

 

https://learn.microsoft.com/en-us/power-bi/create-reports/desktop-grouping-and-binning?wt.mc_id=DP-M...

 





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

Proud to be a Super User!




Hi @ryan_mayu, this is really interesting. I didn't know about this. I'll check this out when I have time (currently at work so I can't). 

 

If this solves the problem, I'll let you know. 

 

Thanks for the navigation! 

SamWiseOwl
Super User
Super User

Hi @Data_BS 

You need to Append a new row to the table with "Other" in both the country and the colour columns.

This is used to check which row we are on in the visual.

SamWiseOwl_0-1728984362289.png

Field Parameters: https://learn.microsoft.com/en-us/power-bi/create-reports/power-bi-field-parameters

Let you swap which column is in the visual.

Create a measure:

Sales =
 var curr = CALCULATE(sum('Table'[Flag]))
 var total = CALCULATE(sum('Table'[Flag]),REMOVEFILTERS('Table'[Country],'Table'[Favourite Colour]))
 var per = curr/total
var sel = MAXX('Choose category',[Choose category])
 var colour = SUMMARIZE(ALLSELECTED('Table'),'Table'[Favourite Colour], "Percent",
  CALCULATE(sum('Table'[Flag]))/CALCULATE(sum('Table'[Flag]),REMOVEFILTERS('Table'[Country],'Table'[Favourite Colour])))
  var country = SUMMARIZE(ALLSELECTED('Table'),'Table'[Country], "Percent"
 ,CALCULATE(sum('Table'[Flag]))/CALCULATE(sum('Table'[Flag]),REMOVEFILTERS('Table'[Country],'Table'[Favourite Colour])))


var final =
SWITCH(
    TRUE()
    ,sel = "Country" && SELECTEDVALUE('Table'[Country]) = "Other"
    ,sumx(filter(country, [Percent] <=0.1), [Percent])
    ,SELECTEDVALUE('Table'[Favourite Colour]) = "Other"
    ,sumx(filter(colour, [Percent] <=0.1), [Percent])
    ,per <= 0.1
    ,BLANK()
    ,per)
return final
   
This tests if the selected item is Colour or Category, calculates which rows are below 10% and returns the appropriate calculation.
Hope this helps!
 

If you are happy with this answer please mark as a solution for others to find !

Kudos are always appreciated! Check out our free Power BI video courses.

Hi @SamWiseOwl. I'm at work at the moment but I'll explore this as soon as I get time. Thanks for providing this, I'll keep you updated. Absolute legend. 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

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.