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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
redalert787
Helper II
Helper II

% of grand total only against top category (but showing lower level categories)

Hello, 

 

I am trying to solve an problem where I'd like to create a measure that shows the % of grand total for our top 10 models names of products against their top level category. The example here is I'd like to show the top 10 products in our "apparel & accessories" division but I'd like to also show which sub-category those model names belong to (For example, if they are in our sub-category of Ski or running). The issue I'm facing is that the calculation works fine when I only show the model name or model name with the top category (Apparel & accessories) but the moment I bring in the sub-category (ski, running etc) the measure calculates the % against the total of the sub-category and not the top category. 

 

here is a screen shot of the measure I created: 

 

redalert787_0-1645690570003.png

 

Here is a screenshot of the table without the sub-category and the % working okay:

redalert787_1-1645690615363.png

 

 

And here is a snapshot of the sub-category included and the measure not working properly anymore:

 

redalert787_2-1645690663484.png

 

 

I think I am writing the equation incorrectly, so if someone can help I would appreciate it. 

 

P.S - if anyone has any suggestions on how to visualize this better than just a boring table...I'm very open to suggestions 🙂 

 

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @redalert787 

 

You can try the following methods.

Top 10 = 
CALCULATE(SUM('Table'[Invoiced Sales]),
          TOPN(10,allselected('Table'),[Invoiced Sales],DESC), VALUES('Table'[Model name]))
% of total sales = 
DIVIDE([Top 10], CALCULATE(SUM('Table'[Invoiced Sales]),ALLSELECTED()))

vzhangti_1-1646041000041.png

vzhangti_0-1646040973747.png

The presence of Famliy does not affect the sorting.

 

Best Regards,

Community Support Team _Charlotte

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

View solution in original post

4 REPLIES 4
v-zhangti
Community Support
Community Support

Hi, @redalert787 

 

You can try the following methods.

Top 10 = 
CALCULATE(SUM('Table'[Invoiced Sales]),
          TOPN(10,allselected('Table'),[Invoiced Sales],DESC), VALUES('Table'[Model name]))
% of total sales = 
DIVIDE([Top 10], CALCULATE(SUM('Table'[Invoiced Sales]),ALLSELECTED()))

vzhangti_1-1646041000041.png

vzhangti_0-1646040973747.png

The presence of Famliy does not affect the sorting.

 

Best Regards,

Community Support Team _Charlotte

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

amitchandak
Super User
Super User

@redalert787 , Try measures like

 


Top 10= calculate([Invoice Sales], TOPN(10,allselected(Product[Product]),[Invoice Sales],DESC), values(Product[Product]))

% of total sales = divide([Top 10], [Invoice Sales])

or
% of total sales = divide([Top 10], calculate([Invoice Sales],allselected() ))

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi @amitchandak ,

 

Thanks for your response. I have a question regarding the top 10 measure: 

 

What do you mean by "DESC" in the measure? 

@redalert787 , desc for descending sort

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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!

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Feb2025 NL Carousel

Fabric Community Update - February 2025

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