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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
vanvir
New Member

DAX - Rank duplicates in sequence

Hi experts group, I have searched the forum, but can't find the solution on my issue.

I need your help to write DAX code on how to rank the duplicates in sequence.

This is the data and I'd like to achieve the result as below in Count Duplicate column

TypeCount duplicate
a0
a1
b0
c0
b1
c1
c2
a2

The aim is to keep the 1st duplicates and remove the rest of duplicates using filter.

Thank you.

1 ACCEPTED SOLUTION
some_bih
Super User
Super User

Hi @vanvir for possible solution, please create two columns, Index and Count Formula.

Index column should be created by Power Query, choose From 1.

Second column, Count Formula is calculated column with formula below. Output is same as yours.

 

Did I answer your question? Kudos appreciated / accept solution!

Link for how to do it below 

https://support.microsoft.com/en-us/office/add-an-index-column-power-query-dc582eaf-e757-4b39-98e6-b... 

 

Count Formula =
VAR __currentvalue=Sheet1[Type]
VAR __current_index=Sheet1[Index]
VAR _count_filtering=
CALCULATE(
    COUNTROWS(
        FILTER(
            Sheet1,
            Sheet1[Type]=__currentvalue
        )
    ),
    ALLEXCEPT(Sheet1, Sheet1[Type]),
    Sheet1[Index]<=__current_index
)
VAR _Result=
_count_filtering-1 --forcing to count 0 (alternative change Index to 0)
RETURN _Result

 

Output

some_bih_0-1694159879277.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @vanvir ,

Could you tell me if your problem has been solved? If it is, kindly Accept it as the solution. More people will benefit from it. Or if you are still confused about it, please feel free to let me know.

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

some_bih
Super User
Super User

Hi @vanvir for possible solution, please create two columns, Index and Count Formula.

Index column should be created by Power Query, choose From 1.

Second column, Count Formula is calculated column with formula below. Output is same as yours.

 

Did I answer your question? Kudos appreciated / accept solution!

Link for how to do it below 

https://support.microsoft.com/en-us/office/add-an-index-column-power-query-dc582eaf-e757-4b39-98e6-b... 

 

Count Formula =
VAR __currentvalue=Sheet1[Type]
VAR __current_index=Sheet1[Index]
VAR _count_filtering=
CALCULATE(
    COUNTROWS(
        FILTER(
            Sheet1,
            Sheet1[Type]=__currentvalue
        )
    ),
    ALLEXCEPT(Sheet1, Sheet1[Type]),
    Sheet1[Index]<=__current_index
)
VAR _Result=
_count_filtering-1 --forcing to count 0 (alternative change Index to 0)
RETURN _Result

 

Output

some_bih_0-1694159879277.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!






Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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