Forum Discussion

joshua1990's avatar
joshua1990
Post Prodigy
4 years ago

Rank based on two columns

Hi experts!

I know, there have been a lot of posts regarding this, but they have not been useful for me.

The objective is to have a ranking based on two columns.

 

I have a dimension table (Table Dim) that lists all of our products.

Then I have a table (Table Trans) that some transactional values in different columns.

There is the first column called Column1 and another one called Column2.

Now I would like to build a ranking for each product based on Column2 as the first priority and Column1 as the second priority.

Using this DAX Measure I get the ranking for each column:

 

 

Rank1 =
    RANKX ( ALLSELECTED ( 'Table Dim'[Product] ), [Column1] )

 

 

 

 

Rank2 =
    RANKX ( ALLSELECTED ( 'Table Dim'[Product] ), [Column2] )

 

 

 

 

As a result, now I have the following:

ProductRank1Rank2Rank Total
A1104
A5222
A3311
A4433
A250

5

 

The Rank Total column shows the result that I need.

 

How is this possible using DAX?

6 Replies