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

RANKX Issues - Beginner woes

Hoping to get some help here with RANKX.  I have scoured the boards and tried almost all suggestions to no avail trying to get RANKX to work properly. Below is my scenario.

1.  created a measure 'Total Sales' [

Total Sales = SUMX('dim-INVOICE','dim-INVOICE'[SalesAmt])]

2. Applied RANKX to the total sales measure to rank it by value and the image below is what i get which is obviously wrong. [

Rank = RANKX(ALL('dim-INVOICE'), [Total Sales])

] I am at a loss of what is going wrong here.  TAll fields are in the same table.

rankx_problem.jpg

 

9 REPLIES 9
amitchandak
Super User
Super User

Anonymous
Not applicable

I was able to go through the articles and I decided to try sample data that I generated.  I am still getting the same issues.  I have included the pbix file i am using in hopes anyone can help glean anything wrong that I am doing.  Any assistance will be appreciated.

Thank you.

 

RankingProblem.PBIX 

Hi @Anonymous ,

 

We can try to use the following measures to meet your requirement:

 

Rank_SUM = RANKX(ALLSELECTED(RankingTest), [TotalSales_SUM],,ASC,Dense)

 

Rank_SUMX = RANKX(ALLSELECTED(RankingTest), [TotalSales_SUMX],,ASC,Dense)

 

Rank_CASUM = RANKX(ALLSELECTED(RankingTest), [TotalSales_CASUM],,ASC,Dense)

 

Rank_CASUMX = RANKX(ALLSELECTED(RankingTest), [TotalSales_CASUMX],,ASC,Dense)

 

3.jpg

 

 
If it doesn't meet your requirement, Could you please show the exact expected result based on the Tables that you have shared.

Best regards,
 
Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Thank you very much.

If you are look at the bottom of your table, rank 47 is appearing twice and the total sales value is different so someting tells me it is ranking something else and not the total sales value.  At any rate I believe the highest rank will be 33.

What I am hoping for is a proper ranking of the total sales as depicted in the attached images.

 

top of tabletop of tablebottom of tablebottom of table

Hi @Anonymous ,

 

Sorry for our late reply, we can use the following measures to meet your requirement:

 

Rank_SUM = 
RANKX (
    CALCULATETABLE (
        DISTINCT ( 'RankingTest'[ItemNumber] ),
        ALLSELECTED ( 'RankingTest' )
    ),
    CALCULATE ( [TotalSales_SUM] ),
    ,
    ASC,
    DENSE
)

 

Rank_SUMX = 
RANKX (
    CALCULATETABLE (
        DISTINCT ( 'RankingTest'[ItemNumber] ),
        ALLSELECTED ( 'RankingTest' )
    ),
    CALCULATE ( [TotalSales_SUMX] ),
    ,
    ASC,
    DENSE
)

 

Rank_CASUM = RANKX (
    CALCULATETABLE (
        DISTINCT ( 'RankingTest'[ItemNumber] ),
        ALLSELECTED ( 'RankingTest' )
    ),
    CALCULATE ( [TotalSales_CASUM] ),
    ,
    ASC,
    DENSE
)

 

Rank_CASUMX = 
RANKX (
    CALCULATETABLE (
        DISTINCT ( 'RankingTest'[ItemNumber] ),
        ALLSELECTED ( 'RankingTest' )
    ),
    CALCULATE ( [TotalSales_CASUMX] ),
    ,
    ASC,
    DENSE
)

 

10.jpg


Best regards,

 

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Thank you for the response.  

Unfortunately, it is not working in my powerBI file. 

 

Possibly my file is now corrupted!  I have used the function in a different situation and it worked however in this instance it is not working.  I settled for using the RANK.EQ alternative, only it added a few more steps to get to the result I wanted.

 

Anonymous
Not applicable

Thank you.  I will review the articles in hopes to shed some light.

kentyler
Solution Sage
Solution Sage

So, looking at the total sales measure... each item has multiple invoices...and your summing them up ?





Did this post answer your question? Mark it as a solution so others can find it!

Help when you know. Ask when you don't!




Join the conversation at We Talk BI find out more about me at Slow BI


Anonymous
Not applicable

correct!

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.