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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Venkat124
Frequent Visitor

Display Slices in Pie chart based on parameter values (Top N + Others)

Hi All,

 

I am hoping someone can help me out with this. I feel like I am close but just not getting the results I need. 

 

I have Pie chart which displays sales state wise, I need to display legend values (slices) based on the parameter number with respect to sales values rank wise.

 

Scenario 1: 

If I select parameter value as 5, the pie chart should display 6 Slices,

5 Slices - States with Top 5 sales

6th Slice -Should club remaining States and display as  "Others" with Sum of Sales for remaining States

 

Here is the screenshot below attached, kindly help me.

 

Image1.PNG

1 ACCEPTED SOLUTION
v-jianboli-msft
Community Support
Community Support

Hi @Venkat124 ,

 

Based on your description, I have created a simple sample:

vjianbolimsft_0-1673580109957.png

Please try:

First create a new table for slicer:

For Slicer = 
var _a = SUMMARIZE('Table',[State],"Rank",RANKX(ALL('Table'),CALCULATE(SUM('Table'[Value]),ALLEXCEPT('Table','Table'[State]))))
var _b = UNION(_a,{("Others",0)})
return _b

Output:

vjianbolimsft_1-1673580147513.png

Create a parameter for slicer:

vjianbolimsft_2-1673580241534.png

Then Create a measure and apply it to the Pie chart's visual level filter:

Measure = 
var _a = IF(MAX('For Slicer'[Rank])<=SELECTEDVALUE(Parameter[Parameter]),1)
return SWITCH(TRUE(),
ISFILTERED(Parameter[Parameter]),_a,
NOT(ISFILTERED(Parameter[Parameter]))&&MAX('For Slicer'[State])<>"Others",1)

vjianbolimsft_3-1673580275852.png

Then create a measrue and apply it to the value:

SumValue =
VAR _a =
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER ( 'Table', [State] = MAX ( 'For Slicer'[State] ) )
    )
VAR _b =
    SELECTCOLUMNS (
        FILTER ( ALL ( 'For Slicer' ), [Rank] > SELECTEDVALUE ( Parameter[Parameter] ) ),
        "Others", [State]
    )
VAR _c =
    CALCULATE ( SUM ( 'Table'[Value] ), FILTER ( 'Table', [State] IN _b ) )
RETURN
    IF ( MAX ( 'For Slicer'[State] ) = "Others", _c, _a )

vjianbolimsft_4-1673580363246.png

Final output:

vjianbolimsft_5-1673580380410.png

Best Regards,

Jianbo Li

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

2 REPLIES 2
v-jianboli-msft
Community Support
Community Support

Hi @Venkat124 ,

 

Based on your description, I have created a simple sample:

vjianbolimsft_0-1673580109957.png

Please try:

First create a new table for slicer:

For Slicer = 
var _a = SUMMARIZE('Table',[State],"Rank",RANKX(ALL('Table'),CALCULATE(SUM('Table'[Value]),ALLEXCEPT('Table','Table'[State]))))
var _b = UNION(_a,{("Others",0)})
return _b

Output:

vjianbolimsft_1-1673580147513.png

Create a parameter for slicer:

vjianbolimsft_2-1673580241534.png

Then Create a measure and apply it to the Pie chart's visual level filter:

Measure = 
var _a = IF(MAX('For Slicer'[Rank])<=SELECTEDVALUE(Parameter[Parameter]),1)
return SWITCH(TRUE(),
ISFILTERED(Parameter[Parameter]),_a,
NOT(ISFILTERED(Parameter[Parameter]))&&MAX('For Slicer'[State])<>"Others",1)

vjianbolimsft_3-1673580275852.png

Then create a measrue and apply it to the value:

SumValue =
VAR _a =
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER ( 'Table', [State] = MAX ( 'For Slicer'[State] ) )
    )
VAR _b =
    SELECTCOLUMNS (
        FILTER ( ALL ( 'For Slicer' ), [Rank] > SELECTEDVALUE ( Parameter[Parameter] ) ),
        "Others", [State]
    )
VAR _c =
    CALCULATE ( SUM ( 'Table'[Value] ), FILTER ( 'Table', [State] IN _b ) )
RETURN
    IF ( MAX ( 'For Slicer'[State] ) = "Others", _c, _a )

vjianbolimsft_4-1673580363246.png

Final output:

vjianbolimsft_5-1673580380410.png

Best Regards,

Jianbo Li

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

Thank you so much for help Jianbo Li,

 

But I have different dimensions also apart from State, like as I mentioned in the screenshot- dynamic slicer (Category, city, country/Region, customer name, product name) coming from different dimension tables

 

So do I need to create multiple tables. If I create single table for each dimension (Var _a), then how can I consider the ranking

 

Please help me for this scenario with dynamic slicer (coming from multiple dimension tables)

Once again many thanks.

 

 

Thanks & Regards

Venkat T

 

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.