Showing results for 
Search instead for 
Did you mean: 
Resolver IV
Resolver IV

Compare rows in two arrays when not all columns are identical

Here's the problem set:  A SQL database is maintained by a LOB application.  For one table, whenever a new row is added, I have a flow that is triggered which creates a corresponding row in a SharePoint list; that list has more columns than the SQL table for additional processing.  To add a bit, there is a corresponding SQL table containing rows that are related to the table above, linked by a key value.  Each of these records is also copied to another SharePoint list.


When the LOB application updates, as opposed to creating new records, it merely updates the row in the first SQL table but completely replaces all the rows in the second table.  Several conditions can result:

  • some of the rows in the second SQL table may match those in SP based on three column values; these would be considered as unchanged
  • some of the rows in the second SQL table may have no matches in SP based on the three columns; these would be considered to be new rows in SP.
  • some of the rows in the SP list may have no matches in the new SQL rows, based on the three fields; these would be considered as rows to be deleted

My approach was to use Filter Array between the two actions Get rows (for SQL) and Get items (for SharePoint).  Because there are column differences, contains or does not contain won't work as they will never match completely.


Here's what I hoped would work:  Use Filter Array following the Get rows and Get Items (the Get rows has a filter that only gets the rows associated with the changed row in the first table, and the Get items does something similar so the two arrays have just records that correspond the way the bullet points above describe; they are specific and related groupings).


I manually entered in advanced mode


@equals(outputs('Get_Line_Items_from_original_SO')?[colA'],),outputs('Get rows (V2) from SQL for all SO Line items')?['colA'])


and then tried to extend it by prefacing equals with @And, then adding a similar expression for equals using colB then a third for colC.


I keep getting formatting errors: Condition is too complex or invalid. Unable to switch to basic mode.


Am I on the right path?  Is this too much for Filter Array, and even if there is a format error, would the result of the Filter Array be the rows that match on the three columns?


Pulling my hair out over this so any help keeps me from going bald.  Thanks.

Resolver IV
Resolver IV

I have a hint on how to do this from some experimental testing.  For each array, use a Select action and define the three elements to compare.  Then filter on the two outputs of the select using contains (or does not contain).  The result of the Filter array will be an array that would be the result of comparing two identical arrays but now is based on the columns in the Select action.


Great, but I still need the many, many fields in the two almost identical column arrays, so I now need to figure out how to go from the Select reduced data back to the original arrays.  Maybe Apply to each?  I will see.

Solution Sage
Solution Sage

I think I worked out one way to do this. 

  • Created two simple arrays - one with three columns (vArray1) and another (vArray2) with the same first two columns (ID and Category).
  • Initialize an array called vFieldConcat to hold the concatenated values of the fields to be used for comparison (ID and Category in this case)
  • Used an ATE to populate that array with the concatenated values from vArray2
  • Filtered vArray1 with this expression - 
    contains(variables('vFieldConcat'), concat(item()?['ID'], item()?['Category'])) is equal to true()



    Hopefully you can adapt this approach.



Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about the Power Platform, follow me on Twitter or subscribe on YouTube.

@mahoneypa HoosierBI on YouTube

 That may have effect as the two select actions I outlined in the reply to myself: it delivers a condensed array that can be compared, but then it seems I have no way to get back to the original array elements.  I need all those columns to take additional actions (i.e., create new items in SP).


What I am going to test today is to use the select and a filter array combination to get a new matched up array (or unmatched array) then use a ATE on that to get the rows/items that  I would need to update or delete.  It would be lovely if the Filter array would allow something like 


@And(equals('array1')['col1'],('array2')['col1]), equals('array1')['col2'],('array2')[col2']), equals('array1')['col3'],('array2')['col3'}))


because the execute time would be much faster than one or more ATE loops.  If this could be figured out, it would be a major find for me.

Note that in my suggestion it is the original array that is being filtered.  The concatenation allows you to compare 2+ columns to filter to where they match on those columns, and you can do what you need from there.



Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about the Power Platform, follow me on Twitter or subscribe on YouTube.

@mahoneypa HoosierBI on YouTube

Finally getting back to working on this after some travels and other tasks.


Interestingly, I have gone down a similar path but have stumbled on getting farther.  Here's what I did:


  • Created an array variable with [] as it's initial value
  • I then walked through my SP list items and added those to the array where (in my case) the data value indicates that I want to keep the item data
  • I then removed all of the SP list items whether or not they were added to the array variable
  • I then walked through the SQL array of the new/changed/deleted items, creating a new SP list item for each one

What I want to do in that Apply loop is then look at the array and see if there is a matching value so I can, after creating a new SP list item, update the columns I want to carry  forward.  What I have not figured out is the syntax to do that.


First, the dynamic content only exposes the array variable name, not the column names in the array.  Do I reference those as varArray["colName"]?  Even more so, how do I "walk through the array rows inside an ATE loop walking through the SQL rows, meaning refer to the current SQL item column names inside the ATE?

I kinda ask the same questions if a Filter Array action is inside the ATE.  What is the syntax to refer to current row in ATE and the array variable?  Worse, I am uncertain if the Filter Array just returns an array of the compared values or the entire array?  I need all those other fields for a selected array row.


Hope this makes sense.


Helpful resources


Celebrating the May Super User of the Month: Laurens Martens

  @LaurensM  is an exceptional contributor to the Power Platform Community. Super Users like Laurens inspire others through their example, encouragement, and active participation. We are excited to celebrated Laurens as our Super User of the Month for May 2024.   Consistent Engagement:  He consistently engages with the community by answering forum questions, sharing insights, and providing solutions. Laurens dedication helps other users find answers and overcome challenges.   Community Expertise: As a Super User, Laurens plays a crucial role in maintaining a knowledge sharing environment. Always ensuring a positive experience for everyone.   Leadership: He shares valuable insights on community growth, engagement, and future trends. Their contributions help shape the Power Platform Community.   Congratulations, Laurens Martens, for your outstanding work! Keep inspiring others and making a difference in the community!   Keep up the fantastic work!        

Check out the Copilot Studio Cookbook today!

We are excited to announce our new Copilot Cookbook Gallery in the Copilot Studio Community. We can't wait for you to share your expertise and your experience!    Join us for an amazing opportunity where you'll be one of the first to contribute to the Copilot Cookbook—your ultimate guide to mastering Microsoft Copilot. Whether you're seeking inspiration or grappling with a challenge while crafting apps, you probably already know that Copilot Cookbook is your reliable assistant, offering a wealth of tips and tricks at your fingertips--and we want you to add your expertise. What can you "cook" up?   Click this link to get started:   Don't miss out on this exclusive opportunity to be one of the first in the Community to share your app creation journey with Copilot. We'll be announcing a Cookbook Challenge very soon and want to make sure you one of the first "cooks" in the kitchen.   Don't miss your moment--start submitting in the Copilot Cookbook Gallery today!     Thank you,  Engagement Team

Announcing Power Apps Copilot Cookbook Gallery

We are excited to share that the all-new Copilot Cookbook Gallery for Power Apps is now available in the Power Apps Community, full of tips and tricks on how to best use Microsoft Copilot as you develop and create in Power Apps. The new Copilot Cookbook is your go-to resource when you need inspiration--or when you're stuck--and aren't sure how to best partner with Copilot while creating apps.   Whether you're looking for the best prompts or just want to know about responsible AI use, visit Copilot Cookbook for regular updates you can rely on--while also serving up some of your greatest tips and tricks for the Community. Check Out the new Copilot Cookbook for Power Apps today: Copilot Cookbook - Power Platform Community.  We can't wait to see what you "cook" up!    

Welcome to the Power Automate Community

You are now a part of a fast-growing vibrant group of peers and industry experts who are here to network, share knowledge, and even have a little fun.   Now that you are a member, you can enjoy the following resources:   Welcome to the Community   News & Announcements: The is your place to get all the latest news around community events and announcements. This is where we share with the community what is going on and how to participate.  Be sure to subscribe to this board and not miss an announcement.   Get Help with Power Automate Forums: If you're looking for support with any part of Power Automate, our forums are the place to go. From General Power Automate forums to Using Connectors, Building Flows and Using Flows.  You will find thousands of technical professionals, and Super Users with years of experience who are ready and eager to answer your questions. You now have the ability to post, reply and give "kudos" on the Power Automate community forums. Make sure you conduct a quick search before creating a new post because your question may have already been asked and answered. Galleries: The galleries are full of content and can assist you with information on creating a flow in our Webinars and Video Gallery, and the ability to share the flows you have created in the Power Automate Cookbook.  Stay connected with the Community Connections & How-To Videos from the Microsoft Community Team. Check out the awesome content being shared there today.   Power Automate Community Blog: Over the years, more than 700 Power Automate Community Blog articles have been written and published by our thriving community. Our community members have learned some excellent tips and have keen insights on the future of process automation. In the Power Automate Community Blog, you can read the latest Power Automate-related posts from our community blog authors around the world. Let us know if you'd like to become an author and contribute your own writing — everything Power Automate-related is welcome.   Community Support: Check out and learn more about Using the Community for tips & tricks. Let us know in the Community Feedback  board if you have any questions or comments about your community experience. Again, we are so excited to welcome you to the Microsoft Power Automate community family. Whether you are brand new to the world of process automation or you are a seasoned Power Automate veteran - our goal is to shape the community to be your 'go to' for support, networking, education, inspiration and encouragement as we enjoy this adventure together.     Power Automate Community Team

Hear what's next for the Power Up Program

Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram, including a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the link below to sign up today!  

Tuesday Tip | How to Report Spam in Our Community

It's time for another TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.   As our community family expands each week, we revisit our essential tools, tips, and tricks to ensure you’re well-versed in the community’s pulse. Keep an eye on the News & Announcements for your weekly Tuesday Tips—you never know what you may learn!   Today's Tip: How to Report Spam in Our Community We strive to maintain a professional and helpful community, and part of that effort involves keeping our platform free of spam. If you encounter a post that you believe is spam, please follow these steps to report it: Locate the Post: Find the post in question within the community.Kebab Menu: Click on the "Kebab" menu | 3 Dots, on the top right of the post.Report Inappropriate Content: Select "Report Inappropriate Content" from the menu.Submit Report: Fill out any necessary details on the form and submit your report.   Our community team will review the report and take appropriate action to ensure our community remains a valuable resource for everyone.   Thank you for helping us keep the community clean and useful!

Users online (6,343)