dimension.top
on that returned dimension object.
columnName - Creates a nested column with the name provided
allData = this.universe.column.find('ID').dimension.top(Infinity);
return d
not return d.value
async function spendByMonth(parent, level) {
//parent = 'Spine';
//level = 1;
console.log(parent);
console.log(level);
var levelKey = hierarchyLevels[level+1];
var monthlySpend = await allData.query({
groupBy: function(d) {
return [d.month, d[levelKey]];
},
select: {
$count: true,
total_spend: {
$sum: 'spend'
}
}
});
console.log(monthlySpend);
if ( parent != 'root') {
await allData.filter(hierarchyLevels[level], parent, false, true);
}
var filteredSpend = monthlySpend.data.filter(function(d) {
return Math.floor(d.value.total_spend.sum) > 0;
});
var pivotedSpend = pivotArray(filteredSpend);
console.log(pivotedSpend);
return pivotedSpend;
}
monthlySpend
returns the correct values for total_spend, but not at the appropriate level of the hierarchy.
filterAll
on allData
before I call this function each time.