Forum Discussion

JMHenriques's avatar
JMHenriques
Frequent Visitor
4 years ago
Solved

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...
  • VahidDM's avatar
    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/