Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
Hi All,
I have a Pie chart where each sub-category contributing to the total sales.
Now, I have a requirement that the pie chart should show only top 5 sub-category and remaining should be in Others part.
How can we do that using DAX?
Any Help would be Appriciated...
Thanks.
Solved! Go to Solution.
I think you can build a calculated column by DAX to show new subcategorys with Top5 and Others.
My Sample:
Top5 Flag is a calculated column.
Top5Flag =
VAR _Rank =
RANKX (
'Table',
CALCULATE (
SUM ( 'Table'[Value] ),
FILTER ( 'Table', 'Table'[SubCategory] = EARLIER ( 'Table'[SubCategory] ) )
),
,
DESC,
DENSE
)
RETURN
IF ( _Rank <= 5, 'Table'[SubCategory], "Others" )
Result:
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
I am getting an error, saying SUM function cannot work with STRING. Please guide me. I am looking for the same soluction.
What is the type of data you are using? Do you want to make a sum of a field? A count?
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsHello all,
Would you please explain, how you created Calculated column? My query is not working.
I think you can build a calculated column by DAX to show new subcategorys with Top5 and Others.
My Sample:
Top5 Flag is a calculated column.
Top5Flag =
VAR _Rank =
RANKX (
'Table',
CALCULATE (
SUM ( 'Table'[Value] ),
FILTER ( 'Table', 'Table'[SubCategory] = EARLIER ( 'Table'[SubCategory] ) )
),
,
DESC,
DENSE
)
RETURN
IF ( _Rank <= 5, 'Table'[SubCategory], "Others" )
Result:
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Check this detailed explanation about how to create the dinamic others part then you can use in any chart.
https://blog.gbrueckl.at/2019/05/power-bi-dynamic-topn-others-with-drill-down/
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsIf you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
| User | Count |
|---|---|
| 45 | |
| 43 | |
| 39 | |
| 19 | |
| 15 |
| User | Count |
|---|---|
| 68 | |
| 65 | |
| 31 | |
| 28 | |
| 24 |