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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.