pnp / blog

holds all blogs published on the Microsoft 365 Platform Community blog
https://pnp.github.io/blog
MIT License
70 stars 102 forks source link

Comparing two arrays without an apply to each? #1137

Open utterances-bot opened 1 year ago

utterances-bot commented 1 year ago

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/

trusu15 commented 1 year ago

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.

tomskelly89 commented 7 months ago

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?

DamoBird365 commented 7 months ago

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.

singhharmanjit1901 commented 7 months ago

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 commented 7 months ago

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!