I'm trying to figure out how to remove an item in an array that are duplicates, but have different values in one field. I only want to keep one of them based on the value in that field.
My array looks like this:
[
{
"First Name": "John",
"Last Name": "Adams",
"ID Number": "101011001",
"Status": "FT"
},
{
"First Name": "John",
"Last Name": "Adams",
"ID Number": "101011001",
"Status": "PT"
},
{
"First Name": "Sue",
"Last Name": "Jones",
"ID Number": "102020102",
"Status": "FT"
},
{
"First Name": "Mary",
"Last Name": "Smith",
"ID Number": "103020304",
"Status": "FT"
},
{
"First Name": "Mike",
"Last Name": "Littleson",
"ID Number": "102050607",
"Status": "FT"
}
]
The first two records are the same person, but they have a different value in the status field. How can I remove the one where status equals PT and keep the one where it equals FT? There will be several records like this in the array.
I know you can do a quick 'union' to basically compare the array to itself and it will spit out an array without duplicates, but that's only if the full record is duplicate across all values.
union(variables('ArrayName'),variables('ArrayName'))
In this case, I have a record where everything is the same except the status value. It's basically a list of employee records that shows their first and last name, email, employee ID, and status of full time or part time. Some employees are listed as both FT and PT because they have multiple positions, but I'd like to remove any that are PT when they exist as both.
So, how to compare items in an array that have multiple values and compare the one's that have the same ID and remove each where status equals PT, keeping those that equal FT.
Thanks in advance for any insight on how to do this!