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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

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! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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