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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

Measure to rank off two columns

My data has the following structure:

AccountExposureCredit Rating
ABC22M25%
CatDog21M14%
Elephant30M14%
Dinosaur28M8%
Spider18M8%

 

I want a rank measure that uses both credit rating and exposure, and also filtering on exposure >

In this example, the ranks would be:

AccountRank
ABC1
CatDog3
Elephant2
Dinosaur4
Spider(blank)
1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @Anonymous ,

Here are the steps you can follow:

1. Create calculated column.

Rank_ex =
IF(
    'RankTable'[Exposure]>=20000000,
RANKX('RankTable','RankTable'[Exposure],,ASC),BLANK())
Rank_cre =
IF(
    'RankTable'[Exposure]>=20000000,
RANKX('RankTable','RankTable'[Credit Rating],,ASC),BLANK())
Ranx3 =
'RankTable'[Rank_ex]+'RankTable'[Rank_cre]+'RankTable'[Rank_cre]

2. Create measure.

Rank =
IF(
    MAX('RankTable'[Ranx3])=BLANK(),BLANK(),
RANKX(ALL('RankTable'),CALCULATE(SUM('RankTable'[Ranx3])),,DESC))

3. Result:

vyangliumsft_0-1644384969019.png

 

Best Regards,

Liu Yang

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

3 REPLIES 3
v-yangliu-msft
Community Support
Community Support

Hi  @Anonymous ,

Here are the steps you can follow:

1. Create calculated column.

Rank_ex =
IF(
    'RankTable'[Exposure]>=20000000,
RANKX('RankTable','RankTable'[Exposure],,ASC),BLANK())
Rank_cre =
IF(
    'RankTable'[Exposure]>=20000000,
RANKX('RankTable','RankTable'[Credit Rating],,ASC),BLANK())
Ranx3 =
'RankTable'[Rank_ex]+'RankTable'[Rank_cre]+'RankTable'[Rank_cre]

2. Create measure.

Rank =
IF(
    MAX('RankTable'[Ranx3])=BLANK(),BLANK(),
RANKX(ALL('RankTable'),CALCULATE(SUM('RankTable'[Ranx3])),,DESC))

3. Result:

vyangliumsft_0-1644384969019.png

 

Best Regards,

Liu Yang

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

TheoC
Super User
Super User

Hi @iab_pbi 

 

Refer to this article: https://www.sqlbi.com/articles/rankx-on-multiple-columns-with-dax-and-power-bi/

 

Another way to achieve what you're after is by doing the following calculated column:

 

Ranking = 

RANKX ( 
    ALLSELECTED ( 'Table'[Account] ) , 
        CALCULATE ( SUM ( 'Table'[Exposure] ) - ( SUM ( 'Table'[Exposure] ) * SUM ( 'Table'[Credit Rating] )
      )

 

I've basically applied the logic that the Exposure Amount less the risk factor associated with the Credit Rating (i.e. Risk Factor = Exposure Amount - ( Exposure Amount * Credit Rating ).  You can modify how you prefer.


All the best.

Theo

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

Anonymous
Not applicable

I tried that suggestion but it didn't work.  If I use this formula, I get the right accounts showing up, but I need to also add in ranking by exposure.

 

Rank S&P Usage =
var currentqtr = CALCULATE(MAX(Account_Data[Rank Quarter]),ALL(Account_Data))
return
CALCULATE(RANKX(ALLSELECTED(Account_Data[Mapped Account Name]),CALCULATE(SUMX(Account_Data,Account_Data[Numeric S&P with Median]),Account_Data[rank Quarter]=currentqtr,Account_Data[Exposure]>=20000000)))
 
How do I add in ranking by exposure as well?

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.