This looks similar to what this user was trying to do: Filtering an array based on multiple conditions, without iterator and filter? - #5 by make.beginner
Iterate - filter - aggregate for each set of data, OR you can run some JavaScript custom code to do it all in a single operation.
You gotta show us the rest of the scenario to see where the 24 bundles are coming from. Try to reduce that to a single bundle (array) first.