04-17-2020 05:03 AM
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
}
]
}
]
04-17-2020 05:56 AM
What was the expression you tried that didn’t work?
04-22-2020 04:29 AM
I was able to use the reduce function to handle this. I made a simple mistake in one of my attempts and abandoned it too quickly.
04-26-2020 07:32 AM
Hi @wcl3y2
i tried to implement using aggregate snap.
testW3C_2020_04_26 (1).slp (6.0 KB)