Filtering an array based on multiple conditions, without iterator and filter?

Hello everyone,

I have an array that looks like this, usually containing around 3000 colllections:

{
    "myArray": [
        {
            "value": 123.56,
            "currency": "usd",
            "merchant": "Shop Next Door, Ltd.",
            "status": "failed",
            "date": "2024-02-05"
        },
        ...
        {
            "value": 765.43,
            "currency": "eur",
            "merchant": "Paris Night Club, SARL",
            "status": "authorized",
            "date": "2024-02-04"
        }
    ]
}

Is there a way to filter this array based on multiple conditions (for example, status = authorized and currency = eur) other than using the iterator + filter method?

My goal is to create custom reports based on this array without having to waste too many operations.

Thank you in advance.

Welcome to the Make community!

Using Iterator and Filter by itself doesn’t “waste” operations.

You’ll need to Iterate, Filter, and immediately re-aggregate back into an array.

This will only take TWO operations.

Alternatively, see if your external service has a module that allows you to insert filters in the Trigger module to filter out items you don’t need.

Links

Here are some useful links and guides you can use to learn more on how to use the Make platform, apps, and app modules. I found these useful when I was learning Make, and hope they might benefit you too —

General

Help Center Basics

Articles & Videos

3 Likes

Thank you!

This is my current approach but, as there are almost 20 reports based on that array, that means 40 operations just to prepare the data for reporting.

I am looking for a way that would work the same way as Linq in C#, for example.

Or, in Make environment, the Map function that would either map more keys or would take more arguments.

Do you mean you have 20 different arrays? In your original question you only mentioned one array.

What does your scenario look like, and could you provide some insight as to why you need to do the above (Iterate-Filter-Aggregate) 20 times?

2 Likes

Thank you.

This is the scenario screenshot.

There’s only one source array, but for every metric I want to appear in the reports (for instance, total value of all transactions that were authorized in USD), I need to iterate the array, apply the filter and sum it.

I’d love to be able to sum such filtered values in a single step.

Looks like you’ll benefit from actually running some code, so that you can complete all of this in a single module.

Usually when I want to run JavaScript, I’ll use the

  • 0CodeKit “Run JavaScript JS-Code” module, or
    Screenshot_2024-02-06_191503

  • Custom JS “Execute a Custom Javascript” module
    Screenshot_2024-02-06_191554

There may be other integrations supporting other coding languages, but I’m only familiar with JS.

2 Likes

Great, thank you!

I’ll give this a try.

No problem, glad I could help!

If you need any assistance with creating custom JS, feel free to start a new topic for this.

1. If you have a new question in the future, please start a new thread. This makes it easier for others with the same problem to search for the answers to specific questions, and you are more likely to receive help since newer questions are monitored closely.

2. The Make Community guidelines encourages users to try to mark helpful replies as solutions to help keep the Community organized.

This marks the topic as solved, so that:

others can save time when catching up with the latest activity here, and

  • allows others to quickly jump to the solution if they come across the same problem

To do this, simply click the checkbox at the bottom of the post that answers your question:
Screenshot_2023-10-04_161049

3. Don’t forget to like and bookmark this topic so you can get back to it easily in future!

2 Likes