Forum Discussion
JMHenriques
4 years agoFrequent Visitor
Calculated column to identify duplicates with filters
Hi everyone, I need to create a calculated column (named ParentorChild in the example below) that identify me, for each week, the first duplicated ID as "Parent" and the remaining ones as "chil...
- 4 years ago
Hi JMHenriques
Try this code to add a calculated column:
ParentorChild = VAR _A = CALCULATE ( COUNTROWS ( 'Table' ), FILTER ( 'Table', 'Table'[UniqueID] <= EARLIER ( 'Table'[UniqueID] ) && 'Table'[WeekYear] = EARLIER ( 'Table'[WeekYear] ) && 'Table'[Someother_ID] = EARLIER ( 'Table'[Someother_ID] ) ) ) RETURN IF ( _A = 1, "Parent", "Child" )output:
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: www.linkedin.com/in/vahid-dm/
VahidDM
Super User
4 years agoHi JMHenriques
Try this code to add a calculated column:
ParentorChild =
VAR _A =
CALCULATE (
COUNTROWS ( 'Table' ),
FILTER (
'Table',
'Table'[UniqueID] <= EARLIER ( 'Table'[UniqueID] )
&& 'Table'[WeekYear] = EARLIER ( 'Table'[WeekYear] )
&& 'Table'[Someother_ID] = EARLIER ( 'Table'[Someother_ID] )
)
)
RETURN
IF ( _A = 1, "Parent", "Child" )
output:
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: www.linkedin.com/in/vahid-dm/