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 / I want to know how to ...
Power Automate
Answered

I want to know how to compare the values of array A and array B.

(0) ShareShare
ReportReport
Posted on by 15

Hi. I want to know if the values in the String array 'keywordArr' contain the values of the String array 'disasterArr'. (If you include the value, you want to add the value of array A corresponding to the array called 'matchKeyword'. ) I think I need to turn the double iteration statement, but the flow is not working with the current settings. I'm not sure how to do it, how should I set it up?

keywordArr = [
"Correspondent Yoo Hyun-min",
"Korea Standard Time",
"Yonhap News",
"5.6 magnitude earthquake",
"eastern Virginia",
"German Center",
"Geoscience Research",
"Johannesburg",
"Reuters",
"GFZ"
]

disasterArr=[
"earthquake",
"war",
"hurricane",
"typhoon"
]

The condition is set to "item ('keywordArr')" + contains + "item ('varables ('disasterArr'))".

 

Please share your knowledge. Thank you.

 

jeeelly_1-1689301457698.png

 

jeeelly_0-1689301387485.png

 

Categories:
  • Manish Solanki Profile Picture
    15,169 Moderator on at

    Hi @jeeelly 

     

    There is no need to use nested 'Apply to each' action. You can compare the arrays using single 'Apply to each' action. Please refer the below flow snippet:

    ManishSolanki_0-1689308585388.png

    Expression used for left hand operand is:

    contains(variables('disasterArr'),item())

    Expression used for right hand operand:

    true

     

    In your input arrays there is no common item so for the above inputs it will return false for all iterations.

     

    If this helps & solves your problem, please remember to give a 👍 and accept my solution as it will help others in the future.

     

    Thanks

  • Verified answer
    v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @jeeelly ,

     

    The expression is wrong. Please try:

    vbofengmsft_1-1689313924287.png

     

    Result:

    vbofengmsft_0-1689313842942.png

     

    Best Regards,
    Bof

     

     

  • Chriddle Profile Picture
    8,729 Super User 2026 Season 2 on at

    A way to do this without any loop using xpath:

     

    Chriddle_0-1689343607735.png

    Select

    From: outputs('DisasterArr')

    Map:

    disaster: item()

    elements: 

     

    xpath(
     xml(
     json(
     concat(
     '{"root":{"item":',
     outputs('KeywordArr'),
     '}}'
     )
     )
     ),
     concat(
    	 '//item[contains(text(), ''',
    	 item(),
    	 ''')]/text()'
    	)
    )

     

     

     Output body('Select'):

     

    [
     {
     "diaster": "earthquake",
     "elements": [
     "5.6 magnitude earthquake",
     "5.7 magnitude earthquake"
     ]
     },
     {
     "diaster": "war",
     "elements": [
     "Reuters war"
     ]
     },
     {
     "diaster": "hurricane",
     "elements": []
     },
     {
     "diaster": "typhoon",
     "elements": []
     }
    ]

     

     

  • Chriddle Profile Picture
    8,729 Super User 2026 Season 2 on at

    To extract the (unique) items, add a compose action with following input:

     

    union(
    	xpath(
    	 xml(
    		json(
    		 concat(
    			'{"root":{"item":',
    			body('Select'),
    			'}}'
    		 )
    		)
    	 ),
    	 '//item/elements/text()'
    	),
    	json('[]')
    )

     

     

    This outputs

     

    [
     "5.6 magnitude earthquake",
     "5.7 magnitude earthquake",
     "Reuters war"
    ]

     

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 Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 445

#2
11manish Profile Picture

11manish 345 Super User 2026 Season 2

#3
M Bilal Khan Profile Picture

M Bilal Khan 300

Last 30 days Overall leaderboard