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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register 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.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

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.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

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 Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.