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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
shalabh
Helper I
Helper I

top N with % on total

Hi,

 

I want to show the top 3 verticals by sales as a % of grand total (not top 5 total). 

 

Example

 

IndustrySalesshow in table or stacked column
A4040%
B3030%
C2020%
D6 
E4 
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @shalabh ,

 

Please follow these steps:

  1.        add new measure "SORT"

vyifanwmsft_0-1701222019135.png

SORT = 
RANKX (
    FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Sales] ),
    CALCULATE ( MAX ( 'Table'[Sales] ) ),
    ,
    DESC
)
  1.        add new measure "RESULT"

vyifanwmsft_4-1701223896015.png

 

RESULT = 
VAR _1 =
    SUMX ( ALL ( 'Table' ), 'Table'[Sales] )
VAR _2 =
    MAX ( 'Table'[Sales] ) / _1
RETURN
    IF ( 'Table'[SORT] <= 3, _2, BLANK () )

3.final output

vyifanwmsft_3-1701222145011.png

 

How to Get Your Question Answered Quickly - Microsoft Fabric Community

If it does not help, please provide more details with your desired out put and pbix file without privacy information.

 

Best Regards,

Yifan Wang

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

 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @shalabh ,

 

Please follow these steps:

  1.        add new measure "SORT"

vyifanwmsft_0-1701222019135.png

SORT = 
RANKX (
    FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Sales] ),
    CALCULATE ( MAX ( 'Table'[Sales] ) ),
    ,
    DESC
)
  1.        add new measure "RESULT"

vyifanwmsft_4-1701223896015.png

 

RESULT = 
VAR _1 =
    SUMX ( ALL ( 'Table' ), 'Table'[Sales] )
VAR _2 =
    MAX ( 'Table'[Sales] ) / _1
RETURN
    IF ( 'Table'[SORT] <= 3, _2, BLANK () )

3.final output

vyifanwmsft_3-1701222145011.png

 

How to Get Your Question Answered Quickly - Microsoft Fabric Community

If it does not help, please provide more details with your desired out put and pbix file without privacy information.

 

Best Regards,

Yifan Wang

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

 

swikritee_p
Resolver II
Resolver II

@shalabh , You can create a measure 

 

% of Top 3 = Divide(
Sumx(keepfilters(topn(3, allselected('Table'[Industry]) ,Sum('Table'[Sales]), desc)),CALCULATE(Sum('Table'[Sales]))) ,
Calculate(sum('Table'[Sales]) , topn(3, allselected('Table'[Industry]) ,Sum('Table'[Sales]), desc)))

 

swikritee_p_0-1701164988094.png

 

@swikritee_p 

I tried this but it is showing all the industries. I want to show only say top 3 industries and percentage contribution of each against the total

 

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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