Are you aware you can back a pivot table by a function since recently ?
This might be a fairly involved approach for goals which have workaround with the existing low-code configuration options, but this approach should give you full flexibility.
This is an example function:
interface PivotData {
entity: string;
period: string;
metrics: {
totalValue: number;
growthRate: number;
}
}
function generatePivotData(): PivotData[] {
const entities = ["EntityA", "EntityB", "EntityC", "EntityD", "EntityE", "EntityF"];
const periods = ["Period1", "Period2", "Period3", "Period4"];
// Placeholder data
const data: {[key: string]: number[]} = {
EntityA: [100, 150, 200, 250],
EntityB: [10, 15, 18, 20],
EntityC: [50, 70, 80, 90],
EntityD: [30, 40, 50, 60],
EntityE: [5, 8, 12, 15],
EntityF: [20, 25, 30, 28]
};
const pivotData: PivotData[] = [];
entities.forEach(entity => {
periods.forEach((period, index) => {
const currentValue = data[entity][index];
const previousValue = index > 0 ? data[entity][index - 1] : 0;
const growthRate = index > 0 ? ((currentValue - previousValue) / previousValue) * 100 : 0;
pivotData.push({
entity,
period,
metrics: {
totalValue: currentValue,
growthRate: parseFloat(growthRate.toFixed(2))
}
});
});
});
return pivotData;
}
Of course be aware that triggering a lot of functions can incur a significant cost, but this should give you a flexible approach.