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
pkoel-asb
Helper V
Helper V

Rank within a sub category

Hello,

 

I am trying to rank a seies of values. Here is a sample:

 

VendorID     Total     Classification

1                   5           N

2                   2           N

3                   7           P

4                   3           P

5                  8            E

 

I would like to rank the vendors within the classification. Here is what I tried, but I get an error:

PFP Ranking = RANKX(
FILTER(
'PFP Ranking'[Classification]
),
'PFP Ranking'[Total])
)
 
Any Ideas?
 
Cheers,
 
Peter
1 ACCEPTED SOLUTION
v-alq-msft
Community Support
Community Support

Hi, @pkoel-asb 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

Table:

c1.png

 

You may create a calculated column or a measure as below.

Calculated column:

 

Rank Column = 
RANKX(
    FILTER(
       ALL('Table'),
       [Classification]=EARLIER('Table'[Classification])
    ),
    [Total]
)

 

Measure:

 

Rank Measure = 
RANKX(
    FILTER(
        ALL('Table'),
        [Classification]=MAX('Table'[Classification])
    ),
    CALCULATE(SUM('Table'[Total]))
)

 

 

Result:

c2.png

 

Best Regards

Allan

 

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

2 REPLIES 2
Anand24
Super User
Super User

Hi @pkoel-asb ,

 

Create a new calculated measure with below DAX:

Rank_Measure =
RANKX(
FILTER(
ALL('Table'[VendorID],'Table'[Classification]),
'Table'[Classification]=MAX('Table'[Classification])
),
CALCULATE(SUM('Table'[Total]))
)

 

Give a thumbs up if this post helped you in any way and mark this post as solution if it solved your query !!!

v-alq-msft
Community Support
Community Support

Hi, @pkoel-asb 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

Table:

c1.png

 

You may create a calculated column or a measure as below.

Calculated column:

 

Rank Column = 
RANKX(
    FILTER(
       ALL('Table'),
       [Classification]=EARLIER('Table'[Classification])
    ),
    [Total]
)

 

Measure:

 

Rank Measure = 
RANKX(
    FILTER(
        ALL('Table'),
        [Classification]=MAX('Table'[Classification])
    ),
    CALCULATE(SUM('Table'[Total]))
)

 

 

Result:

c2.png

 

Best Regards

Allan

 

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

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.