blog icon indicating copy to clipboard operation
blog copied to clipboard

Comparing two arrays without an apply to each?

Open utterances-bot opened this issue 2 years ago • 5 comments

Comparing two arrays without an apply to each?

I have two arrays in Power Automate, whilst very similar in structure (key/value pairs) the unique ID for both arrays is named differently (id vs PersonId) but I want to compare both and return only those that do not appear in the Array 1.

https://pnp.github.io/blog/post/comparing-two-arrays-without-an-apply-to-each/

utterances-bot avatar Mar 14 '23 16:03 utterances-bot

When I try this flow I can only get it to filter a single instance of a personID. So if I have 20 duplicate items it will still pass through 19 of them.

trusu15 avatar Mar 14 '23 16:03 trusu15

very interesting, would this method work if we were pulling information from an HTTP request to populate a sharepoint that would have EmployeeID, FirstName, LastName, JobTitle, Deparment, LineManager, StartDate, LeavingDate

These fields would be held in a sharepoint list to build flows off of but we'd want to keep this list up to date, so if for example only the JobTitle changed how would we achieve just the update of that column in the sharepoint list for that item?

tomskelly89 avatar Feb 08 '24 13:02 tomskelly89

I've an updated video demo'ing this technique here https://youtu.be/4IphRdADJBc.

Tom regarding your Q, what makes each of those items in the list unique? If you want to update or insert, this technique could be utlised to create two arrays and then apply update or insert logic as appropriate.

DamoBird365 avatar Feb 29 '24 16:02 DamoBird365

I tried this but there is a shortcoming. If the array is just based on text values lets say array 1 is ["abc","def"] and the array 2 contains ["abcdef","defabc"] the filter array returns []. This means that the case matching is not happening. Is there a solution for that?

singhharmanjit1901 avatar Mar 05 '24 10:03 singhharmanjit1901

Sorry I had entered the wrong value in the select function and hence it wasn't working for me. Please ignore my message above! I really like your videos DamoBird365! Amazing work! Keep it up!

singhharmanjit1901 avatar Mar 05 '24 11:03 singhharmanjit1901