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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Anonymous
Not applicable

RankX ordered by Text in Category

Hi,
Is it possible to make RankX column ordered by Name in Category
like in the picture

Galat198_2-1610901501202.png

 

My try is not working...

Name_Rank =
RANKX(
FILTER('Table','Table'[name]=EARLIER('Table'[name])),
CALCULATE(
max(
'Table'[name]
),
ALLEXCEPT(Table,Table[category],Table[name])
),,DESC,Dense
)

What I need to insert in Calculate ??

1 ACCEPTED SOLUTION

@Anonymous 

 

You can try the following measure:

If you want to add more filters make sure you declare the variable on top and then insert it in the ALLSELECTED area.

The following returns the same results

 

Sorting Rank = 
VAR _category = MAX ('Table'[Category] )
--VAR _secondvariable = MAX ( Sheet1[p_type] )
Return
    RANKX (
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[Category] = _category
  --              && Sheet1[p_type] = current_type
        ),
        CALCULATE ( MAX ( 'Table'[name] ) ),
        ,
        ASC,
        DENSE
    )

 

View solution in original post

3 REPLIES 3
themistoklis
Community Champion
Community Champion

Hello @Anonymous ,

 

Please try the following formula:

 

Rank = 
RANKX (
    FILTER ('Table', 'Table'[Category] = EARLIER('Table'[Category]) ), -- Grouping Column
    'Table'[Name],                                                     -- Sorting Column
    , ASC
)

 

rank.PNG

 

Anonymous
Not applicable

Hi,
This good solution, but I have other columns in the table (this table only an example)
So I think needs to be any "all" function in the "calculate" function, but in calculate is possible using only aggregation...

@Anonymous 

 

You can try the following measure:

If you want to add more filters make sure you declare the variable on top and then insert it in the ALLSELECTED area.

The following returns the same results

 

Sorting Rank = 
VAR _category = MAX ('Table'[Category] )
--VAR _secondvariable = MAX ( Sheet1[p_type] )
Return
    RANKX (
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[Category] = _category
  --              && Sheet1[p_type] = current_type
        ),
        CALCULATE ( MAX ( 'Table'[name] ) ),
        ,
        ASC,
        DENSE
    )

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.