Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Find duplicates in a column and give a value

Hi All, i want to create a calculates column with specific value when duplicates are found. if the colum has duplicates give "duplicated" ths formula i have used is:   Formula = IF(CALCULATE(CO...
  • edhans's avatar
    5 years ago

    You can use this in a Calculated Column Anonymous 

     

    Duplicates = 
    VAR varCurrentValue = 'Sample'[Column1]
    VAR varInstances = 
        COUNTROWS(
            FILTER(
                'Sample',
                'Sample'[Column1] = varCurrentValue
            )
        )
    var Result = 
        IF(
            varInstances > 1,
            "Duplicate",
            "Unique"
        )
    RETURN
        Result


    You don't need ALL or CALCULATE. ALL in this context removes filters. Tables and Calculated Columns have no filter context, only row context.

     

  • edhans's avatar
    edhans
    4 years ago

    You can try this:

    Duplicates =
    VAR varCurrentValue = 'Sample'[Column1]
    VAR varInstances =
        COUNTROWS(
            FILTER(
                'Sample',
                'Sample'[Column1] = varCurrentValue
                    && NOT 'Sample'[Column1]
                    IN {
                    "House",
                    "Table"
                }
            )
        )
    VAR Result =
        IF(
            varInstances > 1,
            "Duplicate",
            "Unique"
        )
    RETURN
        Result