我正在使用此 Google Data Studio codelabs 处理 npm 下载计数器 连接器。 在 getFields() 函数中,我创建了两个维度(“day”和“packageName”)和一个指标(下载量)。 但在Data Studio中,所有字段都显示为维度,没有指标。
getFields()函数
function getFields() {
var fields = cc.getFields();
var types = cc.FieldType;
var aggregations = cc.AggregationType;
fields
.newDimension()
.setId('packageName')
.setName('Package')
.setType(types.TEXT);
fields
.newDimension()
.setId('day')
.setName('Date')
.setType(types.YEAR_MONTH_DAY);
fields
.newMetric()
.setId('downloads')
.setName('Downloads')
.setType(types.NUMBER)
.setAggregation(aggregations.SUM);
return fields;
}
最佳答案
“绿色”数字字段当前是预期输出(因此,在本例中,显示为“绿色”维度的下载
数字字段是预期行为),并且是 31 Oct 2019 Update 的一部分Google Data Studio,“Improved data modeling in Data Sources”。
“蓝色”指标字段是预先聚合的值,例如 Google Analytics 数据源中的指标或在各自的数据源中创建 Aggregated Calculated Field,例如 SUM(Downloads)
它将显示为“蓝色”指标。
要详细说明更新,请添加发行说明中的部分:
You don't need to take any action. Charts and calculated fields used in your reports will work as before the upgrade. However, if you create or edit data sources from flexible schema (or tabular) data sets, such as Sheets or BigQuery, you may notice that number fields that previously appeared as metrics (blue fields) with an aggregation of None now appear as green dimensions with a new Default Aggregation of Sum. This change has no effect in existing charts, but makes it easier to use these fields in more flexible ways.
关于javascript - 为什么所有字段在 Data Studio 中都显示为维度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66857201/