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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
PowerBITestingG
Resolver I
Resolver I

Rank duplicates

Hi all

 

So using this DAX 

duplicate = CALCULATE(COUNTA(column1),ALLEXCEPT(table,column1))
 
I can get the duplicated values. 
 
What I am trying to do is to label one of the duplicates as 1 and the rest as 0, or just rank them, as long as I get a way to filter unique values
 
Like:
Column1 Result
AAA           1
AAA            0
BBB            1
BBB            0
BBB             0
 
Any ideas?
1 ACCEPTED SOLUTION

 

I solved by creating a new calculated column that uses RAND() for breaking ties

 

rankduplicates =
RANKX (
    FILTER (
       table,
        table[column1]
            EARLIER ( table[column1] )
    ),
    table[notie] -- Just RAND()
)

View solution in original post

2 REPLIES 2
tamerj1
Super User
Super User

Hi @PowerBITestingG 
What other columns you have? Do you have date or inex column(s)? Can you add index column? In other words how do you define the first record? By time or or index?

 

I solved by creating a new calculated column that uses RAND() for breaking ties

 

rankduplicates =
RANKX (
    FILTER (
       table,
        table[column1]
            EARLIER ( table[column1] )
    ),
    table[notie] -- Just RAND()
)

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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

Top Kudoed Authors