n179911a
n179911a

Reputation: 155

How to rank a column of a Table in Power BI with a condition

I have this table in PowerBI

Name Count Type
A 1 1
B 2 2
C 1 2
D 2 1

How can I Rank the value of Count column only if Type is same? i.e. have a rank when Type equals to 1, have a rank when Type is 2?

So that I get

Name Count Type Rank
A 1 1 2
B 2 2 1
C 1 2 2
D 2 1 1

Upvotes: 0

Views: 115

Answers (1)

Peter
Peter

Reputation: 12365

Use this calculated column

Rank = 
VAR ThisType = 'Table'[Type]
RETURN
    RANKX(
        FILTER(
            'Table',
            'Table'[Type] = ThisType
        ),
        'Table'[Count],
        ,
        ,
        DENSE
    )

enter image description here

Upvotes: 1

Related Questions