为什么所有字段在 Data Studio 中都显示为维度?

Why all fields appear as dimensions in data studio?

我正在使用这个 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;
}

“绿色”数字字段当前是预期的输出(因此,在这种情况下,显示为“绿色”维度的 Downloads 数字字段是预期的行为)并且是 31 Oct 2019 Update to Google Data Studio, which "Improved data modeling in Data Sources".

“蓝色”指标字段将是预先聚合的值,例如 Google 分析数据源中的指标或在您各自的数据源中创建 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.

来源:Announcing data modeling improvements (02 Nov 2019)