web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Removing item in array...
Power Automate
Answered

Removing item in array based on matching criteria in certain values

(0) ShareShare
ReportReport
Posted on by 9

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!
Categories:
I have the same question (0)
  • Verified answer
    v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @Dez_OC :

    I've made a test for your reference:

    vbofengmsft_0-1644218787302.png

    vbofengmsft_1-1644218937750.png

    vbofengmsft_2-1644218949268.png

    Result:

    vbofengmsft_3-1644218974553.png

    Best Regards,

    Bof

     

     

  • takolota1 Profile Picture
    4,980 Moderator on at

    @Dez_OC @v-bofeng-msft 

     

    More efficient way to get unique JSON array records based on select columns:

    https://powerusers.microsoft.com/t5/Power-Automate-Cookbook/Get-Unique-Records/td-p/2191533

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 605

#2
Valantis Profile Picture

Valantis 340

#3
11manish Profile Picture

11manish 284

Last 30 days Overall leaderboard