10-25-2023 03:34 AM
I have an array of the following form:
I want to convert this array of objects into a single object that has the same fields along with Debit_Amount and Credit_Amount fields summed up.
Any help is appreciated!
Solved! Go to Solution.
11-29-2023 12:26 PM
@vgautam64 - I believe this solves your question in the simplest way I can think of. Use a Mapper snap with the following configuration:
It appears to me that you only need the field elements and values from the first group element: $group[0]
The two jsonPath statements are simply pulling all values for the Debit and Credit Amounts into an array of numbers
Finally, the Array.reduce() method is used to aggregate that list of numbers into a final total.
Hope this helps!
10-26-2023 09:31 AM
Anyone?
10-26-2023 09:54 AM
10-26-2023 11:35 PM - edited 10-26-2023 11:45 PM
@vgautam64 As I can't copy your json, have created my own, you can use it-
Data ==>
11-20-2023 05:53 AM
Hi @Supratim,
Thanks for the providing a solution. I tried to validate the expression with the data I have and it seems to work when I validate the pipe. Strangely though, I observe that when I execute (not validate) the pipeline, the mapper that holds the expression only seem to process 50 records and gets stuck processing the 51st doc. But when I validate the pipe I am able to see the preview of 148 documents.
Any idea why this would happen?