Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now
I have to display top N sum based on slicer value and sort them by code Group Ascending and in that group sort by sum values.
e.g N=2
Sample data:
sales=Sum(amount)
Code Group |Name | Sales
B|B1|21
B|B2|51
B|B3|41
A|A1|20
A|A2|50
A|A3|40
C|C1|15
C|C2|25
output:
A|A2|50
A|A3|40
B|B2|51
B|B3|41
C|C2|25
C|C1|15
Solved! Go to Solution.
Hi @Anonymous
You can add a new measure below to sort the column:
Measure 4 =
VAR t =
SUMMARIZE (
ALLSELECTED ( 'Table (2)' ),
'Table (2)'[Code Group],
'Table (2)'[Name],
'Table (2)'[Rank],'Table (2)'[Sales]
)
RETURN
COUNTROWS (
FILTER (
t,
ISONORAFTER (
'Table (2)'[Code Group], SELECTEDVALUE ( 'Table (2)'[Code Group]), DESC,
'Table (2)'[Sales],SELECTEDVALUE('Table (2)'[Sales]),ASC
)
)
)
Hi @Anonymous
Add below calculated column, then filter the rank less than or equal to:
Rank = RANKX(FILTER('Table (2)',[Code Group]=EARLIER('Table (2)'[Code Group])),[Sales],,DESC)
For 'C' rank is showing correctly but order is not correct it should be like first 25 and then 15
Hi @Anonymous
You can add a new measure below to sort the column:
Measure 4 =
VAR t =
SUMMARIZE (
ALLSELECTED ( 'Table (2)' ),
'Table (2)'[Code Group],
'Table (2)'[Name],
'Table (2)'[Rank],'Table (2)'[Sales]
)
RETURN
COUNTROWS (
FILTER (
t,
ISONORAFTER (
'Table (2)'[Code Group], SELECTEDVALUE ( 'Table (2)'[Code Group]), DESC,
'Table (2)'[Sales],SELECTEDVALUE('Table (2)'[Sales]),ASC
)
)
)
You solution works fine but our client don't want to see this extra column in export. I know how to hide it at visual level but we can't hide it in export.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
Check out the February 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 52 | |
| 50 | |
| 34 | |
| 15 | |
| 14 |
| User | Count |
|---|---|
| 93 | |
| 77 | |
| 41 | |
| 26 | |
| 25 |