Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Suggested answer

Show items not in both arrays

Like (0) ShareShare
ReportReport
Posted on 14 Nov 2024 11:56:02 by 2
I am trying to work out how to show items that are not in two arrays.
I have one from a RESTAPI from out finance system that shows what accounts are valid with which cost centres;
[
{
"Acc": "N3200",
"CostC": "W61000"
},
{
"Acc": "N4500",
"CostC": "W62000"
}
]
 
I then have an excel file (neatened a little)
 
[
{
"Acc": "N3200",
"CostC": "W61000"

},
{
"Acc": "N4500",
"CostC": "W61000"

},
{
"Acc": "N3200",
"CostC": "W62000"

},
{
"Acc": "N4500",
"CostC": "W62000
"
}
]
I can use intersect to get the underlined items that are in both arrays.  I can use filter to filter by account and/or cost centre (but that just shows all entries).
 
What I can't work out how to do is filter the excel based array to show the items where a combination of account and cost centre aren't in the RESTAPI array (the bold items).
  • DO-11111502-0 Profile Picture
    2 on 18 Nov 2024 at 11:10:18
    Show items not in both arrays
    I have managed to get this to work but not by using the filter method (that I think should work).
     
    It works if I convert it to xml and add a property (Validation) then filter on validation.
     
     
    If I try to use filter array,  then it filters on Account and CostC separately.  So the returned value is blank (as both N3200/N4500 exist, as well as W61000/W62000).
     
     It could just be a logic issue when combining the two not-contains functions.
     

    and(not(contains(body('SelectRESTAPIAccount'),item()?['Account'])),not(contains(body('SelectRESTAPICostC'),item()?['CostC'])))
  • Chriddle Profile Picture
    7,583 Super User 2025 Season 1 on 14 Nov 2024 at 16:35:33
    Show items not in both arrays
    Filter the objects form Excel with the following:
     
    <array of objects from API> does not contain   @item() 
  • Suggested answer
    David_MA Profile Picture
    10,140 Super User 2025 Season 1 on 14 Nov 2024 at 15:17:35
    Show items not in both arrays
    I think what you are actually asking is how do you find the differences between two arrays rather than what is missing in two arrays. Otherwise, you would need a third array of the values to check if they are missing from the first two arrays.
     
    If this is actually your use case, check out this: List values missing in an array using Power Automate
     
    It has been some time since I used this, but it worked.

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,513 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,606 Most Valuable Professional

Leaderboard
Loading started