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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
ade_kurniawan
Frequent Visitor

Show Top N Rank Category

Dear friends,

 

I want to rank descending some data, then i can flag the category by get the top 2 biggest sub category.

ade_kurniawan_0-1634280207987.png

 

i attach my PBIX here : https://1drv.ms/u/s!AhkGQiSs1aWEo3TBgvcNe_DiqS9r?e=pHEN9w 

 

thanks for help

1 ACCEPTED SOLUTION
CNENFRNL
Community Champion
Community Champion

 

TOP 2 = 
CONCATENATEX(
    TOPN( 2, Sheet1, CALCULATE( SUM( Sheet1[value] ) ) ),
    Sheet1[category],
    ", "
)

 

Screenshot 2021-10-15 140923.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

4 REPLIES 4
CNENFRNL
Community Champion
Community Champion

 

TOP 2 = 
CONCATENATEX(
    TOPN( 2, Sheet1, CALCULATE( SUM( Sheet1[value] ) ) ),
    Sheet1[category],
    ", "
)

 

Screenshot 2021-10-15 140923.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Sir, would you like to send me pbix file please ? thanks

Pls refert to the attached pbix file below.


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

amitchandak
Super User
Super User

@ade_kurniawan , Create Rank in one of the manner and use visual level filter to filter Rank<=2

 

Cat Rank  = Rankx(allselected(Table[Category]), calculate(sum(Table[Value])),,desc)

 

You can also refer this

https://www.sqlbi.com/articles/filtering-the-top-3-products-for-each-category-in-power-bi/

Cat Rank = Rankx(filter(allselected(Table[City],Table[Category]) [City] = Max([City])) , calculate(sum(Table[Value])),,desc)

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors