有没有办法用自定义条件创建用户所需的措施, 动态在剑道数据透视表中。
我发现可以选择创建自定义度量,例如
measures: {
"ChainShare": {
field: "ChainShare",
aggregate: "sum"
},
"DemandIndex": {
field: "DemandIndex",
aggregate: function (value, state, context) {
var dataItem = context.dataItem;
var ChainShare = dataItem.ChainShare;
var GroupShare = dataItem.GroupShare;
// manual aggregation
state.ChainShare = ( state.ChainShare || 0 ) + ChainShare;
state.GroupShare = ( state.GroupShare || 0 ) + GroupShare;
},
result: function(state){
if ( state.ChainShare == 0 || state.GroupShare == 0 ){
return 0;
} else {
return (state.ChainShare / state.GroupShare) ;
}
}
}, "GroupShare": {
field: "GroupShare",
aggregate: "sum"
}
}
但是这个聚合函数是静态的,用户无法为它添加更多条件。
简单地说,我需要动态地从前端创建度量。