Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Checking for different values in duplicates

Good day all,

 

I have a table in Power Bi that looks similar to this:

What I need to get is a column called Age_Check that would output 1 if for every group of records with the same name where there is a difference in age. 

 

Bassicaly, Age_Check should output 0 for all records that do not have a Name repeating (i.e Name_Count is 1) and only process those records that have duplicate names (i.e Name_Count >1). For those duplicates that have different value for Age, the Age_Check should be equal to 1.

  • Anonymous , Seem like missed age logic, Try this

     

    Age_check =
    var _1 = countx(filter(Table,table[Name] = earlier(Table[Name])),Table[Name])
    var _2 = countx(filter(Table,table[Name] = earlier(Table[Name]) && table[Age] = earlier(Table[age])),Table[Name])
    return
    if(_1 >1 && _1<> _2 ,1,0)

6 Replies

  • Anonymous , create a new column like

    new column = if(countx(filter(Table,table[Name] = earlier(Table[Name])),Table[Name])>1,1,0)

    • Anonymous's avatar
      Anonymous
      Not applicable

      amitchandak Please could you input the column names I used in my Example data.

      • amitchandak's avatar
        amitchandak
        Super User

        Anonymous , You have used a name, I used the same

        Age_check = if(countx(filter(Table,table[Name] = earlier(Table[Name])),Table[Name])>1,1,0)

         

        or we can use ID

         

        Age_check = if(countx(filter(Table,table[ID] = earlier(Table[ID])),Table[ID])>1,1,0)