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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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.