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
Claus_Vad
Frequent Visitor

TopN and sum of rest in a 100% stacked bar chart

Hi all

Can anyone help with a measure calculating TopN and sum of rest,to be shown in a 100% stacked bar chart

I've tried following example sqlbi.com

 

Product Ranking =
UNION (
SELECTCOLUMNS (
ALLNOBLANKROW ( 'financials'[Product] ),
"Ranking name", 'financials'[Product],
"Ranking group", "Best Products"
),
{ ( "Other", "Other" ) }
)
 
TopN Sales =
IF (
ISINSCOPE ( 'Product Ranking'[Ranking group] ),
VAR NumOfProducts = 3
VAR RankingGroup =
SELECTEDVALUE ( 'Product Ranking'[Ranking group] )
VAR TopProducts =
TOPN ( NumOfProducts, ALLSELECTED ( 'Product Ranking' ), [Sales Amount] )
RETURN
SWITCH (
RankingGroup,
"Best Products",
CALCULATE ( [Sales Amount], KEEPFILTERS ( TopProducts ) ),
"Other",
IF (
NOT ISINSCOPE ( 'Product Ranking'[Ranking Name] ),
VAR TopAmount =
CALCULATE ( [Sales Amount], TopProducts )
VAR AllAmount =
CALCULATE ( [Sales Amount], ALLSELECTED ( 'Product Ranking' ) )
VAR OtherAmt = AllAmount - TopAmount
RETURN
OtherAmt
)
),
[Sales Amount]
)
 
But the result is not what I want, the TopN Sales show the left Bar Chart, I want it like the right Bar Chart.
 
Claus_Vad_0-1670573858344.png

 Thanks in advance, Claus

 

 

1 REPLY 1
johnt75
Super User
Super User

Try using Ranking Name rather than Ranking Group in the column chart.

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.