RANKX assigning duplicate values even though the values are different

Hi,

I need help with RANKX function.

I need to rank the customers based on the sales and I want to exclude the data that has been filtered and only apply the ranking on what is filtered.

For example, If I choose the month of January, it should calculate the rank based on the sales of the month of January.

Below is the DAX formula I am using:

CustomerRankTEST = IF(    
                                    NOT ISBLANK([TotalSales]),
                                   
                                    RANKX(
                                        ALLSELECTED(Customers),
                                       [TotalSales]
                                    )
                                )
                        

The above formula is assigning the duplicate values to some records even though the values are completely different.

Can you please advise how can I make it work?

Thank you.

Hi @gkhokher

See if this helps you, similar question in the forum.
RANKX displaying duplicate rank despite different quantities - DAX Calculations - Enterprise DNA Forum

Problem with RANKX with certain condition - DAX Calculations - Enterprise DNA Forum

thanks
Keith

Hi @Keith ,

I tried changing my formula as suggested in the solutions that you sent the link for, unfortunately, it is giving me the exact same numbers as my original formula.

Thank you.

well, maybe supplying the expected results and power bi file might help the community too.

I’m learning too, I just saw the links within the forum that might help.

Did you trying searching through learning portal or youtube?

Hi @Keith ,

Yes I did but did not find the solution.

May be @BrianJ can help with this…

Hi @gkhokher. As @Keith suggested, to help the forum members consider options, please provide a sample PBIX that illustrates your issue. Context always affects ranking results unless specifically excluded, which does not appear to be the case here.
Greg

1 Like

Hi @Greg ,

The data in the file is confidential. So, I had to anonymize the data.
I created random sales values etc. and applied the same formula I had on the original file and the formula is working ok on the anonymized file. So, I cannot replicate the issue that I have on the original data.

Any suggestions?

Thank you.

Hi @Greg , @Keith ,

Figured it out. I was the context. I had other columns in table where I was putting the customer ranking column, those columns had duplicates. Removed them and added appropriate ones (which were directly connected to the table) and the formula started working.

Thanks for the help and hints!!