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

Get Fabric Certified for FREE during AI Skills Fest. This week only. Secure your voucher now.

Reply
ngocnguyen
Helper IV
Helper IV

Top 2 category

Hi

I have the input table as below. Is there any way to have the top 2 table ?

Logic for Top 2 Table:. Finding the top 2 category by Amt , then showing up the detail of category by Route

 

Thanks

 

Capture2.PNG

2 ACCEPTED SOLUTIONS

@ngocnguyen I just called my source table Top 2 is all. See PBIX below sig. 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

CNENFRNL
Community Champion
Community Champion

CNENFRNL_0-1664169402095.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

7 REPLIES 7
CNENFRNL
Community Champion
Community Champion

CNENFRNL_0-1664169402095.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!

Hi @CNENFRNL 

Highly appreciate your support. 

is there any way to get the Output as below?
Logic: get top 2 Amt by both CAT & Route

 

Capture.PNG

Greg_Deckler
Community Champion
Community Champion

@ngocnguyen Try:

Table 3 = 
    VAR __Table = SUMMARIZE('Top2',[CAT],"__Amt",SUM('Top2'[Amt]))
    VAR __Table1 = ADDCOLUMNS(__Table,"__Rank",RANKX(__Table,[__Amt]))
    VAR __Categories = DISTINCT(SELECTCOLUMNS(FILTER(__Table1,[__Rank]<3),"__CAT",[CAT]))
RETURN
    FILTER('Top2',[CAT] IN __Categories)


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler 

Many thanks for your support.

However, Top 2 table is the Output, but in your Dax formular, you calling the Top 2 table?, 

It 's a litte bit confusing. Could you please check again?

@ngocnguyen I just called my source table Top 2 is all. See PBIX below sig. 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler 

Thanks so much. So is there any way to get the Ouput by setting up measure. I wana the Ouput can appear in the Report tab in PBI 

@ngocnguyen Sure, you could implement this as a Complex Selector. The Complex Selector - Microsoft Power BI Community



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.