Group and Sum in Expression Language
I am trying to group and sum an amount by two properties with the expression language with no luck. I tried using the reduce function, but it’s not working like it does in traditional javascript. Is there any way to get this to work? Here is my input document:
[
{
“ro”: [
{
“prod”: “product1”,
“div”: “division1”,
“amount”: 178.25
},
{
“prod”: “product1”,
“div”: “division2”,
“amount”: 758.65
},
{
“prod”: “product1”,
“div”: “division2”,
“amount”: 10000.79
},
{
“prod”: “product2”,
“div”: “division2”,
“amount”: 5678.10
}
]
}
]
Here is my expected output:
[
{
“ro”: [
{
“prod”: “product1”,
“div”: “division1”,
“amount”: 178.25
},
{
“prod”: “product1”,
“div”: “division2”,
“amount”: 10759.44
},
{
“prod”: “product2”,
“div”: “division2”,
“amount”: 5678.10
}
]
}
]