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

Pie chart with other category

Hi there, 

I want to get only top N categories based  on their values and create other category. I used rankx dax formula (created column). However, I could not get expected result. What I have to do in order get expected result?

Thanks in advance

 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

hi, @Umidjon 

I am not sure if I understood your question correctly, but please check the below picture and the sample pbix file.

I tried to create a sample pbix file based on the explanation.

I suggest creating a dim-category table like below.

 

Picture2.png

 

Qty Total =
SUM(Sales[Qty])
 
Show Top N =
VAR _topNshow =
SUMX (
KEEPFILTERS (
TOPN (
SELECTEDVALUE ( 'TopN'[TopN] ),
ALLSELECTED ( Categories ),
[Qty Total], DESC
)
),
[Qty Total]
)
RETURN
SWITCH (
TRUE (),
SELECTEDVALUE ( Categories[Category] ) = "Others",
CALCULATE ( [Qty Total], ALLSELECTED ( Categories ) )
- SUMX (
TOPN (
SELECTEDVALUE ( 'TopN'[TopN] ),
ALLSELECTED ( Categories ),
[Qty Total], DESC
),
[Qty Total]
),
_topNshow
)
 
 
 
 

Hi, My name is Jihwan Kim.


If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.


Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

hi, @Umidjon 

I am not sure if I understood your question correctly, but please check the below picture and the sample pbix file.

I tried to create a sample pbix file based on the explanation.

I suggest creating a dim-category table like below.

 

Picture2.png

 

Qty Total =
SUM(Sales[Qty])
 
Show Top N =
VAR _topNshow =
SUMX (
KEEPFILTERS (
TOPN (
SELECTEDVALUE ( 'TopN'[TopN] ),
ALLSELECTED ( Categories ),
[Qty Total], DESC
)
),
[Qty Total]
)
RETURN
SWITCH (
TRUE (),
SELECTEDVALUE ( Categories[Category] ) = "Others",
CALCULATE ( [Qty Total], ALLSELECTED ( Categories ) )
- SUMX (
TOPN (
SELECTEDVALUE ( 'TopN'[TopN] ),
ALLSELECTED ( Categories ),
[Qty Total], DESC
),
[Qty Total]
),
_topNshow
)
 
 
 
 

Hi, My name is Jihwan Kim.


If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.


Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Hi,

 

I am trying to use your solution to show the TopN and the Others in a Pie Chart.  The TopN is working perfectly, but I am not able to get the "others" to display in the chart.  The chart is only showing the TopN.  How can I resolve this?  

Here's the calculation I am using for TopN

Show Top N =
VAR _topNshow =
SUMX (
KEEPFILTERS (
TOPN (
SELECTEDVALUE ( 'TopN'[TopN] ),
ALLSELECTED ( 'Product Totals'[Product Name] ),
[Qty Total], DESC
)
),
[Qty Total]
)
RETURN
SWITCH (
TRUE (),
SELECTEDVALUE ( 'Product Totals'[Product Name]) = "Others",
CALCULATE ( [Qty Total], ALLSELECTED ( 'Product Totals'[Product Name] ) )
- SUMX (
TOPN (
SELECTEDVALUE ( 'TopN'[TopN] ),
ALLSELECTED ( 'Product Totals'[Product Name] ),
[Qty Total], DESC
),
[Qty Total]
),
_topNshow
)
kg4u_0-1666637204069.png

 

 

 

 

 

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.

Top Solution Authors