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
smpa01
Super User
Super User

RANKX tie breaker (DAX not M)

Hello,

 

I am writing a DAX query and my dataset is following.

 

Table = DATATABLE (
        "Account#", INTEGER,
        "total", DOUBLE,
        
        {
            { 980012, 1200 },
            { 980012, 1200 },
            { 980012, 1200 },
            { 980012, 1300 },
            { 980013, 5000 },
            { 980013, 5000 },
            { 980013, 7800 }
        }
    )

 

 

Account#total
9800121200
9800121200
9800121200
9800121300
9800135000
9800135000
9800137800

 

I was wondering if there is a way to create a M like indexing through a calculated column (not meaure) in this table like following. I want to rank the total by Account#-total combined category.

 

Account#totalRank
98001212001
98001212002
98001212003
98001213001
98001350001
98001350002
98001378001

 

I am trying to do this on a temp table through DAX query so I can't go back to M and create an index.

So far I tried this.

cxs.PNG

 

Is there a way to achieve the desired ranking by any chance in DAX query?

 

Thank you in advance.

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
1 ACCEPTED SOLUTION
kentyler
Solution Sage
Solution Sage

Perhaps you could add another column, and in that column use the RAND() function to add a small decimal amount to each total. Then you rank on that column (which should have fewer chances of having a duplicate value), but display the real total column.





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


View solution in original post

5 REPLIES 5
amitchandak
Super User
Super User
kentyler
Solution Sage
Solution Sage

Perhaps you could add another column, and in that column use the RAND() function to add a small decimal amount to each total. Then you rank on that column (which should have fewer chances of having a duplicate value), but display the real total column.





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


@kentylerthanks it worked.

 

I do have a follow-up question for you though out of curiosity. Once RAND() values are obtained in step 1 is there a way to stop that from evaluating agin in subsequent steps/

 

sqaz.PNG

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

I don't understand your question. RAND has to be called for each row or the value it adds will not be different, and thus not able to provide a tie breaker.

 





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


Let me clarify

 

the rand column value in VAR _3 is different than VAR_2.

 

Is there a way to keep the value of "rand" column obtained in VAR_2 unchanged in VAR_3?

VAR _2VAR _2VAR _3VAR _3

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

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.