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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
Sascha
Regular Visitor

ranking duplicates

Hi,

 

I'm looking for a way to 'rank duplicates'.

Basically in a simplified way I have data per customer for differen periods, and I want to rank data based on a combination of this. I can best explain by example, see the table for the result (column 'Desired Rank') I am looking for.

(I later want to use this to be able to filter to only take the first item per client/period etc).

 

Hope someone can help me out! Thanks.

 

Client no.PeriodDesired Rank
100Q11
100Q21
101Q11
101Q12
102Q11
102Q21
102Q22
103Q11
104Q11
104Q12
104Q13
104Q21
1 ACCEPTED SOLUTION

Good points! Giving me the idea of a nice DAX-only solution, that would work in PP as well (Unique row identifier is essential here) 😉

 

RANKX(FILTER(table1; table1[Code]=EARLIER(table1[Code]));[Unique ID];;1)

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

View solution in original post

9 REPLIES 9
Baskar
Resident Rockstar
Resident Rockstar

Cool , I have created one calculated column for this , it is working for me.

 

But u have to create one Index column on this using Power Query. pls look the attachment 

1.JPG

 

 

 

let me know if any help 

Nice, good to see it's possible. However I'm still struggeling. I have to do this in Powerpivot and not sure I can use the provided solutions.

 

I've tried:

Count=calculate(countrows(table1); allexcept(table1; table1[code]))

Rank=RANKX(filter(ALL(table1[Code]);[Client no.]);[Code])

 

ID   Client no.  P      Code     Count   Rank    Desired Rank

345    100    Q1      100Q1          1         1         1

346    100    Q2      100Q2          1         2         1

347    101    Q1      101Q1          2         3         1

348    101    Q1      101Q1          2         3         2

349    102    Q1      102Q1          1         4         1

350    102    Q2      102Q2          2         5         1

351    102    Q2      102Q2          2         5         2

352    103    Q1      103Q1          1         6         1

353    104    Q1      104Q1          3         7         1

354    104    Q1      104Q1          3         7         2

355    104    Q1      104Q1          3         7         3

356    104    Q2      104Q2          1         8         1

Good points! Giving me the idea of a nice DAX-only solution, that would work in PP as well (Unique row identifier is essential here) 😉

 

RANKX(FILTER(table1; table1[Code]=EARLIER(table1[Code]));[Unique ID];;1)

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Hi @Sascha,

 

Thanks for the points, please mark the corresponding reply as answer for help more people.


Best Regards,
Angelia 

Baskar
Resident Rockstar
Resident Rockstar

Desired Rank 

 is already existing column or calculated column ?

 

'Desired Rank' is the outcome I am looking for. So it is not yet an excisiting column in my BI, just created it here to show what I mean.

This looks like a nested index. Have a look how this goes here: https://blog.crossjoin.co.uk/2015/05/11/nested-calculations-in-power-query/

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Yes! That's the type of output I'm looking for. Isn't it possible with Dax ?

Baskars solution is a DAX-version. I'm not aware of a possibility to create the Index-column in DAX.

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

Check out the October 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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