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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

How to Count Duplicate Cells and Return "1" for First Occurences and "0" for others

Hi everyone, are you guys doing well?

I have a complicated challenge here to add a new column to my table,

Basically, I need to count duplicate ID's, and after that, I need to write "1" into one of the X rows that are duplicates,

For example, as in my table below, the ID "X1" repeats 4 times, then I need to write "1" as result into any row, and "0" for the remaining ones,

RodCamargoJr_1-1686581516649.png

 

I have tried to use the expressions Countrows with Earlier function, but It will always give me just the repetition count,

 COUNTROWS(FILTER('Table', EARLIER('Table'[ID]) = 'Table'[ID] ) )

Could you guys help me out with this challenge?
1 ACCEPTED SOLUTION

@Anonymous 

Please try

Expected Result =
IF (
'Table'[Date]
= CALCULATE ( MIN ( 'Table'[Date] ), ALLEXCEPT ( 'Table', 'Table'[ID] ) ),
1,
0
)

View solution in original post

3 REPLIES 3
tamerj1
Super User
Super User

Hi @Anonymous 
Do you have a date or index column?

Anonymous
Not applicable

Hi tamerj1,

Yes, I have a column date, but the column index no,

@Anonymous 

Please try

Expected Result =
IF (
'Table'[Date]
= CALCULATE ( MIN ( 'Table'[Date] ), ALLEXCEPT ( 'Table', 'Table'[ID] ) ),
1,
0
)

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.