Forum Discussion
bojanvelevski
3 years agoValued Contributor
Hi @nirupama,
There’s a group by functionality on the Aggregate snap that will allow you to have the input data in a group after you’re done with your calculations (Aggregation).
Another option is to use a Group by N snap, with 0 in group size which will add all incoming objects to one array. After that, you’ll need to add a Mapper snap with the following expression:
$array.reduce((acc, curr)=> acc + curr, 0)
You probably going to need to amend the expression per your needs. For example if you have an array of objects, and you need to calculate a specific field (ex. “Age”) the expression will look something like this:
$array.reduce((acc,curr)=> acc + curr.Age,0)
Regards,
Bojan