I am looking to generate a pivot table by combining data from two objects using TypeScript functions. My plan is to first join the two objects, create a unified object, and then perform groupBy operations along with aggregate functions like sum and min on selected columns. Can anyone guide me on how to achieve this?
Below is the code snippet that I have attempted:
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
}));
}