I need to create a pivot table based on two objects. For that my first step is to join two objects and then get one combined object through typescript functions. From that object I will groupBy and perform some aggregate functions(sum, min) and take needed columns. please suggest me ways to do this.
I have tried below code:
public async test(p1: ObjectSet<objecta>,c1: ObjectSet<objectb>): Promise<ObjectSet<objectc> {
const [results1, results2]= await Promise.all([
#three dimensional aggregation
p1
.groupBy(a1 => a1.year.topValues())
.segmentBy(a1 => a1.code.byFixedWidth(1))
.sum(a1=>a1.amt),
c1
.groupBy(a1=>a1.yr.topValues())
.segmentBy(a1 => a1.code.byFixedWidth(1))
.sum(a1 => a1.FullAmt),
]);
# results3 is three dimensional aggregation how to convert it to object set?
const results3 = results1.map(itm => ({
...results2.find((item) => (item.yr === itm.yr) && item),
...itm
}));
}
I don't believe this is really supported. Why do you need to return an Object set?
Would it work if you just return a custom structure?
Here's an example written straight into SO, so it may not work verbatim, but it gives you an idea :) i.e.: