Forum Discussion
Hi @JensDeveloper appreciate your help.
In fact, the orderline is not coming in the ‘data’ object. I just transformed it as below to have it part of the data thinking it might help, like using join as below
‘data’ with out orderlines is coming from different snap and orderlines are coming from different snap
please find attached the input jsons and the json that I am trying to achive as final.
Thank you for you help,
Manohar
input_json2_with_orderlines.json (82.4 KB)
input_json1_with_outorderlines.json (23.2 KB)
Final_Expected_Json_structure.json (2.4 KB)
Hey @manohar,
Try the following pipeline. Keep in mind that this will work if you only have these 2 incoming objects.
Structuring Data_2022_11_10.slp (126.1 KB)
- bojanvelevski3 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,
BojanHi @bojanvelevski ,
Thanks you. I tried with group by N(It does batching randomly), but I want to group them based on 3 fields say $A,$B,$C and then I want to do SUM on other field $D.Is there any such functionalities available in snaplogic using mapper?
- bojanvelevski3 years agoValued Contributor
Same thing applies to your use case, just the grouping is a little bit different and you’ll have to use Group by Fields
Related Content
- 4 months ago
- 2 years ago