Comparing items in an array


Hi team, I'm looking for some help with this workflow logic.

I have an API call that fetches hundreds of memberships. It gives me the unique member ID, membership ID and status (active/inactive). One member (mem ID) can have multiple memberships with different statuses. I want to set up a filter that compares all the memberships of the same member, and only make that member ID continue if all his subscriptions are inactive. 

Example:
Member ID 1 has three different membership subscriptions (active, inactive, inactive) -> Member ID 1 does NOT continue in the flow because he still has one active.

Member ID 2 has two memberships (inactive, inactive) -> Member ID 2 can continue because all his subscriptions are inactive.

Thanks in advance!

If I understood your case correctly, an IF statement If {{ $json.membershipFieldName }} type:string contains 'active' would solve your issue(refer to image).

Or use a Filter node with the same logic(refer to image):

Hi Mookie, appreciate the feedback!

Unfortunately, this won’t solve the issue because it will just continue if one of the of the membership subscriptions is inactive (and won’t cross-check other subscriptions for the same member ID).

I need to check for all memberships in the array that have the same member ID, and make sure there are none that are still active. If there’s one that’s active, the member can’t continue in the flow.

Hope this makes sense?

It really seems like a Filter node for me(refer to image). You have an array of members, and an array under members called memberships. You have to loop over each member → filter depending on membership array status → process kept members and continue with the loop.

Hi @Sam_Bastiaens

To filter for members where all their subscriptions are “inactive”, you need to:

  1. Group Memberships: Group all membership records by their unique Member ID.

  2. Check Each Group: For each member’s group of memberships, check if any of them have a status of “active”.

  3. Apply the Filter:

    • If a member has at least one “active” membership, exclude them.

    • If a member has only “inactive” memberships, include them to continue in the workflow.

Quick Implementation Guide:

  • In Make (Integromat): Use the Array Aggregator to group by Member ID. Then, use a Filter to check if the array of statuses for a member does not contain “active”.

  • In Zapier: The most reliable way is to use a Code by Zapier step (Python or JavaScript) to group the memberships and filter out the members with any active subscriptions. The code step would then output only the Member IDs that can continue.

If my reply is helpful, kindly click like and mark it as an accepted solution.
Thanks!

Hi Mookie, appreciate the help so far.

Below I’ll put a screenshot of example data. It’s the same member (mber_1), who has different subscriptions with different statuses. A regular if statement will have the first item continue, but we need to crosscheck if there are no other subscriptions for mber_1 that have a different status. The flow can only continue if ALL subscriptions for that member are inactive. In other words, get notified if member 1 deactivated ALL his subscriptions and has none that are still active.

Oh, now I see. First, you have to aggregate the id field using an Aggregate node. This will turn your data into array under the ID field. After that you can add loop & filter logic.