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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

Help with Rank function

Hello,

 

I am trying to apply RANKX function to show bottom 5 records based on amount which I am able to achieve.

 

Next I want is it should filter my data based on specific condition and then apply rankx fubction.But I am not able to achieve desired result. Need help with DAX to implement the same,

 

e.g: When I apply normal Rank function to show bottom 5 product type by Amount then I get results(A,B,C,D,E)

 

I want dax to show bottom 5 product type by product amount where transaction no >1 i.e (B,C,D,E,F)

 

Product Type        Product Amount       No of Transaction         Rank                    Rank( Excluding transaction where no is >1)

A                            10                              1                                   1

B                            20                              12                                 2                           1

C                            30                              30                                 3                           2

D                           40                              45                                  4                           3

E                            50                              15                                  5                          4

F                            60                              60                                                              5

 

Thanks in advance.

 

 

5 REPLIES 5
Anonymous
Not applicable

Hi,

Create 2 measures as below and drag 'Product Rank' measure in the table:

Total Amount = SUM( Data[ProductAmount] )
Product Rank = 
IF( SUM( Data[NoOfTransactions] ) <> 1,
RANKX( ALL( Data ), [Total Amount], ,ASC ) - 1, "No Rank"
)

Here's what i got:

result.PNG

 

Thanks.

Anonymous
Not applicable

Hi Vaibhav,

 

Thanks ..But some how I am not getting expected results.

 

DAX i m using :

Bottom Rank = if(sum(Query2[NUMBER_TRANSACTIONS])<>1,RANKX(ALL(Query2[DESCRIPTION]),[Amount],,ASC)-1,"No Rank"Rankx.JPG

 

 Am I doing anything wrong?...my rank is not starting with 1.

Kindly suggest.

 

Thanks!

Anonymous
Not applicable

Hi,

Can you try to replace ALL(Query2[DESCRIPTION]) with ALL(Query2)

Thanks.

Anonymous
Not applicable

Hey Thanks @Anonymous 

 

Tried with ALL(Query) still not able to get the correct rank..Please see below.

 

Rankx.JPG

 

Anonymous
Not applicable

Can you share some sample data?

Thanks.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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