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!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
Hi all.
Have a table with data somewhat like this. Shortened for quick reading. Table just called Table1
Week | Year | Category | Sales Value |
1 | 2020 | Type A | 100 |
1 | 2020 | Type B | 200 |
1 | 2020 | Type C | 300 |
2 | 2020 | Type A | 100 |
2 | 2020 | Type B | 200 |
2 | 2020 | Type C | 400 |
3 | 2020 | Type A | 85 |
3 | 2020 | Type B | 200 |
3 | 2020 | Type C | 300 |
1 | 2021 | Type A | 100 |
1 | 2021 | Type B | 200 |
1 | 2021 | Type C | 300 |
I have a duo of measures to go on to different Card Visuals to show the "best" and "worst" performing sales week with the below code (Will just do Best Week as I know we can swap DESC at the end with ASC to get the worst.
Solved! Go to Solution.
@AlexanderPrime , You topN for each category this should work, measure
CALCULATE( max(Table1[Week]), TOPN(1,allselected(Table1[Week]),sum(Table1[Sales Value]), DESC) )
or
CALCULATE( max(Table1[Week]), TOPN(1,allselected(Table1[Week]),sum(Table1[Sales Value]), DESC) , values(Table1[Week]))
or use TOPN from visual level filter
or create a Rank like this and filter at the visual level
refer sub-category rank
For Rank Refer these links
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures
https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns
@AlexanderPrime , You topN for each category this should work, measure
CALCULATE( max(Table1[Week]), TOPN(1,allselected(Table1[Week]),sum(Table1[Sales Value]), DESC) )
or
CALCULATE( max(Table1[Week]), TOPN(1,allselected(Table1[Week]),sum(Table1[Sales Value]), DESC) , values(Table1[Week]))
or use TOPN from visual level filter
or create a Rank like this and filter at the visual level
refer sub-category rank
For Rank Refer these links
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures
https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns
Thank you!
Seems I was having a case of the Wednesdays and didn't think to use the TOPN visual filter, for some reason I was convinced it was only at Measure level, the TOPN Visual filter method worked like a charm.