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

Next 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

Reply
ngocnguyen
Helper IV
Helper IV

Rankx display

Hi

I have table 1 is power BI. I wanna create a matrix like table 2 with below logic:

- Rank by PL & Route: Ranking the Amt by PL Cat & Route

- Rank by Item: Ranking the Amt by Item only 

So, How to make a measure to do it?

 

 

Capture.PNG

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@ngocnguyen , Try ranks like

ranxk(allselected(Table[Item]), calculate(sum(Table[Amount]), allexcept(Table, Table[Item])),,desc,dense)

 

ranxk(Summarize(allselected(Table),Table[PL cat],Table[item] ), calculate(sum(Table[Amount]), allexcept(Table, Table[PL cat], Table[item])),,desc,dense)

 

Measure Rank: https://www.youtube.com/watch?v=DZb_6j6WuZ0&list=PLPaNVDMhUXGaaqV92SBD5X2hk3TMNlHhb&index=40

Power BI Rank Across dimension tables: https://youtu.be/X59qp5gfQoA


https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

v-yanjiang-msft
Community Support
Community Support

Hi @ngocnguyen ,

According to your description, here's my solution. Create calculated columns.

Rank by PL&Route =
RANKX (
    'Table 1',
    SUMX (
        FILTER (
            ALL ( 'Table 1' ),
            'Table 1'[PL Cat] = EARLIER ( 'Table 1'[PL Cat] )
                && 'Table 1'[Route] = EARLIER ( 'Table 1'[Route] )
        ),
        'Table 1'[Amt]
    ),
    ,
    DESC,
    DENSE
)

For the second "Rank by Item", your requirement is Ranking the Amt by Item only, but the result in Table2 is not ranking by item. So I provide two formula here.

If you really want to rank by Item:

Rank by Item =
RANKX ( 'Table 1', 'Table 1'[Item],, ASC )

If you want to get the provided result:

Column =
RANKX (
    FILTER (
        'Table 1',
        'Table 1'[Route] = EARLIER ( 'Table 1'[Route] )
            && 'Table 1'[PL Cat] = EARLIER ( 'Table 1'[PL Cat] )
    ),
    'Table 1'[Amt]
)

Result:

vkalyjmsft_0-1668073721137.png

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ kalyj

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-yanjiang-msft
Community Support
Community Support

Hi @ngocnguyen ,

According to your description, here's my solution. Create calculated columns.

Rank by PL&Route =
RANKX (
    'Table 1',
    SUMX (
        FILTER (
            ALL ( 'Table 1' ),
            'Table 1'[PL Cat] = EARLIER ( 'Table 1'[PL Cat] )
                && 'Table 1'[Route] = EARLIER ( 'Table 1'[Route] )
        ),
        'Table 1'[Amt]
    ),
    ,
    DESC,
    DENSE
)

For the second "Rank by Item", your requirement is Ranking the Amt by Item only, but the result in Table2 is not ranking by item. So I provide two formula here.

If you really want to rank by Item:

Rank by Item =
RANKX ( 'Table 1', 'Table 1'[Item],, ASC )

If you want to get the provided result:

Column =
RANKX (
    FILTER (
        'Table 1',
        'Table 1'[Route] = EARLIER ( 'Table 1'[Route] )
            && 'Table 1'[PL Cat] = EARLIER ( 'Table 1'[PL Cat] )
    ),
    'Table 1'[Amt]
)

Result:

vkalyjmsft_0-1668073721137.png

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ kalyj

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@ngocnguyen , Try ranks like

ranxk(allselected(Table[Item]), calculate(sum(Table[Amount]), allexcept(Table, Table[Item])),,desc,dense)

 

ranxk(Summarize(allselected(Table),Table[PL cat],Table[item] ), calculate(sum(Table[Amount]), allexcept(Table, Table[PL cat], Table[item])),,desc,dense)

 

Measure Rank: https://www.youtube.com/watch?v=DZb_6j6WuZ0&list=PLPaNVDMhUXGaaqV92SBD5X2hk3TMNlHhb&index=40

Power BI Rank Across dimension tables: https://youtu.be/X59qp5gfQoA


https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
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.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.

March Power BI Update Carousel

Power BI Community Update - March 2026

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