cancel
Showing results for 
Search instead for 
Did you mean: 

Help Using Group By!

andre_mangatal
New Contributor

Dear Community

I need your help with understanding the group by in the attached simple pipeline.

I am supplying the Json data and sorting and grouping it by ID as in the picture but for each Group, i.e. ID. Then I need to first determine if a type of address exists e.g. “BUS” business or “RES” residential and then transform, e.g. via a mapper, to output both the business and residential addresses to Mapper variables $Business and $Residential output as one document/record

Thank you very much for your help in advance,
Andre M

JsonSAMPLE groupBy_Sample

13 REPLIES 13

The groupby also included the address

image

I’m not clear on what you’re doing with the Router there.

Perhaps it would be easier if you stated the overall goal. Are you trying to turn the JSON input into a CSV file?

Good day tstack,

Thanks again but if I have two values i wanted to output below, e.g Value and Value2, based on Address: ‘BUS’, how would edit the code below to achieve this?

match $group {
[…, { Address: “BUS”, Value }, …] => Value
}

Thank you very much in advance,
Andre

You can add more property names to the pattern (the left side of the ‘=>’ in the match block) to capture them and make them available for the expression on the right side of the ‘=>’. I’m not sure what you want to do with the value, so I just concatenated them into a single string:

match $group {
[…, { Address: “BUS”, Value, Value2 }, …] => Value + " " + Value2
}

andre_mangatal
New Contributor

Many thanks for the feedback on this. I used it and works good.

-Andre