Forum Discussion

RADical6142's avatar
RADical6142
Copper Contributor
Jul 07, 2022
Solved

Highlight or count duplicates in a single Sharepoint List column

I have a Yes/No column titled "isDuplicate" which I would like to populate based on duplicates located in another column titled SerialNumber. I tried to do this with a calculated column and if statem...
  • PamDeGraffenreid's avatar
    PamDeGraffenreid
    Jul 10, 2022

    RADical6142   Here you go...

     

    Create a variable and connect to your list:

    Now, for each item above - check the list to see if that serial number exists anywhere else in that list.  If it does, increment a variable.  When it's done, update the IsDuplicate field to yes or no.

    In the apply to each

    • set the count back to 0 
    • Get the list items for searching

    Now add another Apply to each and a condition. The condition: if the Serial Number (in the first Get Items) equals the Serial Number (in the second Get Items), increment the variable.  It will always find a match once.  

    After that apply to each, add another condition that checks to see if the count is greater than 1, set IsDuplicate to Yes, if not, set IsDuplicate to No. 

     

     

    That's it, your list should be updated.  Here's a big picture view, beginning to end.

     

    Some thoughts...  

    • I set this to run as recurrence since it will probably take a long time to run depending on how many items are in your list.  You might want to filter that first Get Items to only check items that have been updated since the last time it ran. 
    • If this is a one-time cleanup, maybe set the Serial Number field in SharePoint to Enforce Unique Values

    Here is the json for the Title column.

    {
    "elmType": "div",
    "debugMode": true,
    "txtContent": "@currentField",
    "style": {
    "background-color": "=if([$IsDuplicate] == 'Yes', '#FFFFDD', '')"
    }
    }

     

Resources