I have two arrays
array 1 [apples, peas, pears, grapes],
array 2 [apples, oranges, bananas, peas, carrots]
If the item is in Array 1 my final array basically remove any items it finds a match for from the final array
Final array [ oranges, bananas, carrots]
Can this be done in MS Flow?
Solved! Go to Solution.
Hi @jkeckard007 ,
The array 1 and array 2 that you provided as below are not standard Array type:
array 1 [apples, peas, pears, grapes],
array 2 [apples, oranges, bananas, peas, carrots]
And the standard Array type array 1 and array 2 should as below:
["apples", "peas", "pears", "grapes"]
["apples", "oranges", "bananas", "peas", "carrots"]
Please refer to screenshot below to create the flow:
The flow would run successfully as below:
Best regards,
Alice
Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @jkeckard007 ,
The array 1 and array 2 that you provided as below are not standard Array type:
array 1 [apples, peas, pears, grapes],
array 2 [apples, oranges, bananas, peas, carrots]
And the standard Array type array 1 and array 2 should as below:
["apples", "peas", "pears", "grapes"]
["apples", "oranges", "bananas", "peas", "carrots"]
Please refer to screenshot below to create the flow:
The flow would run successfully as below:
Best regards,
Alice
Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thanks for sharing this solution.
I have been struggling for a while to understand how something like this can be achieved in Power Automate.
I amended your solution to fit my scenario and thought that last "Set Variable2 - ExistinArray1 to False" would not be required but I don't get the right outcome without it. I don't understand why it is required.
If you can still remember why 😊 can you please explain why that last "Set Variable 2" to False is required in the Flow?
Thanks.
The variable is set to false in the outer loop in preparation for the next run of the inner loop. If you don't reset it to false then any further run of the inner loop, after the first positive result, will be true no matter what the comparison result is.
Here's a way to achieve the same with a single loop
https://powerusers.microsoft.com/t5/General-Power-Automate/get-differences-from-2-arrays/td-p/304051
The explanation for the nested loop though is equal parts clear as confusing 😊
Is the condition within the inner not already set to False in the first place? I.e. isn't that the condition that actually allows us to append "false" i.e. unmatching array values into the Final array in the first place?
It still seems to me that we are setting something to false that should already be false.
Would appreciate if you could clarify more, or provide a link to some "stuff" that can explain this set variable concept 🙏
Many thanks for the link you shared to the alternative approach. That was a lot easier for me to understand.
The condition within the inner loop is not setting the variable to false as far as I can see from his screenshots. The scope of the variable is the flow itself so once the inner loop sets it to true, after you make your comparison to check if the variable is false, you must set it back to false so it is not set to true when the inner loop runs again, if you don't then the flow will report a match when in fact there is none.
To be honest, I would have initialized the variable to false because it seems to me the check could fail if no match is found on the first run because the variable would still be null and not false.
Thanks for the responses and the suggestions.
The method has shed light on approaches I had not thought to do.
I will play with this approach and also try the alternative you pointed to. Lots to learn.
You can watch this video to resolve your issue.Also request you to please subscribe this channel
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
Announcing a new way to share your feedback with the Power Automate Team.
Learn to digitize and optimize business processes and connect all your applications to share data in real time.
User | Count |
---|---|
67 | |
22 | |
16 | |
16 | |
11 |
User | Count |
---|---|
133 | |
43 | |
32 | |
32 | |
28 |