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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount 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
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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