Forum Discussion
Display Slices in Pie chart based on parameter values (Top N + Others)
- 3 years ago
Hi Anonymous ,
Based on your description, I have created a simple sample:
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 _bOutput:
Create a parameter for slicer:
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)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 )Final output:
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.
Hi Anonymous ,
Based on your description, I have created a simple sample:
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:
Create a parameter for slicer:
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)
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 )
Final output:
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