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 / Compare if two arrays ...
Power Automate
Answered

Compare if two arrays have the same value

(0) ShareShare
ReportReport
Posted on by 127

Hello Super Community!

 

I gave up on this concept a week ago, then saw a video where the guy did this in 4 minutes https://youtu.be/SFlj1ykpvgM?si=aBUO60wiYcHu44Qz  😕 I tried it with my own data and two hours later...nope!

 

Initialized Variable:  name: First Array, Type: Array

 

[
  {
    "Date array""2024-06-01"
  },
  {
    "Date array""2024-06-02"
  },
  {
    "Date array""2024-06-03"
  },
  {
    "Date array""2024-06-04"
  },
  {
    "Date array""2024-06-05"
  },
  {
    "Date array""2024-06-06"
  },
  {
    "Date array""2024-06-07"
  },
  {
    "Date array""2024-06-08"
  },
  {
    "Date array""2024-06-09"
  },
  {
    "Date array""2024-06-10"
  },
  {
    "Date array""2024-06-11"
  },
  {
    "Date array""2024-06-12"
  }
]
 
Initialized Variable:  name: Second Array, Type: Array
 
[
{
"Date array": "2024-06-06",
"List ID": 11
},
{
"Date array": "2024-06-07",
"List ID": 11
}
]
 
Condition: 
Select an output... 
variables('First Array')
 
variables('Second Array') contains item()
 
 
Condition statement I'm trying to write: if any dates in the Second Array match dates in the First Array, result is TRUE, if not FALSE
Problem: I can't get true results. 
 
Thanks in advance!
 
Screenshot First Array.jpg
Screenshot Second Array.jpg
Screenshot Condition.jpg
Categories:
I have the same question (0)
  • Chriddle Profile Picture
    8,697 Super User 2026 Season 1 on at

    Challenge accepted, 2 minutes 😀

    Chriddle_0-1718294205022.png

    Compose contains your First array

    Compose 2 contains your Second array

     

    Select

    From: @{outputs('Compose_2')}

    Date array: @{outputs('Compose_2')}

     

    Compose 3

    @{equals(intersection(outputs('Compose'), body('Select')), body('Select'))}

  • Chriddle Profile Picture
    8,697 Super User 2026 Season 1 on at

    If you need true/false per item, replace Compose 3 with the following Select:

    Chriddle_0-1718295058101.png

    From: @{body('Select')}

    Map:  @addProperty(item(), 'isInFirstArray', contains(outputs('Compose'), item()))

    Chriddle_1-1718295182886.png

     

  • Dianez Profile Picture
    127 on at

    So, here's the rub. I have to leave the data as-is in the second array. These two arrays are outputs from the original flow, which is much more difficult. After 4 days, I gave up because this was the part that wasn't working. Every single error imaginable came up. There wasn't just one error.

     

    I'll need the "List ID" ( number 11) later on in the flow to update a column in SharePoint.

  • Verified answer
    Chriddle Profile Picture
    8,697 Super User 2026 Season 1 on at

    That's no problem:

    Chriddle_2-1718298712148.png

     

    Select

    From: @{outputs('Compose_2')}

    CompareItem: @JSON(concat('{"Date array": "', item()['Date array'], '"}'))

    Item: @item()

     

    Select 2

    From: @{body('Select')}

    Map: @addProperty(item(), 'isInFirstArray', contains(outputs('Compose'), item()['CompareItem']))

     

    Chriddle_3-1718298988461.png

     

    All items in the resulting array have a property "Item" that contains the original item.

  • Dianez Profile Picture
    127 on at

    0_0 wow this is such an eloquent solution without using 3 Apply to each's. This work wayyyy better.  Can I ask you a favor? How do you get the List ID value by itself. I was able to get the "11" with a lot of effort, but perhaps you know a better way? 

     

    item()?['Item/List_ID']  doesn't work. And neither did, item()?['Item']['List_ID']

     

    In any case, thank you so much!

  • Verified answer
    Chriddle Profile Picture
    8,697 Super User 2026 Season 1 on at

    Chriddle_0-1718349099638.png

    Filter array filters the output of the flow above for items that are in the first array.

     

    Select 3 collects all their List IDs

    Map: @item()['Item']['List ID']

     

    Chriddle_1-1718349325852.png

     

  • Dianez Profile Picture
    127 on at

    Thank you so much!!!!

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Valantis Profile Picture

Valantis 389

#2
Vish WR Profile Picture

Vish WR 331

#3
David_MA Profile Picture

David_MA 298 Super User 2026 Season 1

Last 30 days Overall leaderboard