Array subtraction

I have two Arrays in my flow. Let’s assume Arr1 & Arr2. I want to derive values which are in Arr1 and not in Arr2. So how can I subtract one array from another array here in Make? If we can’t subtract two arrays then is there any other approach to achieve this requirement?

I see noone has answered your question in over 1 month. How sad. I’ll give it a try now. If I understand your question you wish to create a scenario which effectively returns items in array1 that are only in array1 and not in both array1 and array2.

We will start with a simple case of a simple array. Evolving this to an array of collections would be more complex because you will need logic to identify whether you want to match by key, by value or by a combination of both (most likely this one).

array1 = [a,b,c,d]
array2 = [b,c]

Your desired result is [a,d]. I hope that is correct.

This 4 operation scenario snippet will do what you want. You can expand on this to support more complex arrays. I’ve tested it with strings and numbers.

Here’s the
arraysubtraction.json (6.9 KB)
for you to mess around with. If Make.com had a filter() function this could be done in 1 operation.

3 Likes

Greetings @Krutik

Here’s a “quick” video that addresses your question. Just kidding, it’s 18m long :smiley: But, I wanted to use your question as an example for demonstrating several concepts in Make, specifically custom apps, and custom IMLfs.

Video Link: Make (Integromat) Custom App Exercise Easy and "cheap" array comparisons with custom IML functions - YouTube
Link to try out the custom app and get the blueprint: Make Custom App – Create a simple difference array comparison app - ifOnly Solutions

Let me know if you have any questions!

4 Likes

Most people would stop at 9 minutes into the video and call it a day. But not @luke.ifonly_solution

He describes how he built the app. A master class for advanced Make users. And a must watch for anyone who wants to wield the full power of Make.

Well done Luke! You are truly an automation master.

You Must Star Wars GIF by Regal

2 Likes