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

标签 javascript google-apps-script looker-studio google-apps-script-api

我正在使用此 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.

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

关于javascript - 为什么所有字段在 Data Studio 中都显示为维度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66857201/

相关文章:

javascript - 如何在服务中使用参数+依赖注入(inject)

javascript - 我怎样才能访问用户在 VueJS 的这些 v-text-fields 中输入的数据?

performance - 在 Google Apps Script 中获取边框的最有效方法是什么

google-apps-script - 无法设置复选框数据验证

mysql - Google Data Studio - 防止聚合

javascript - Google Data Studio 自定义图表

javascript - HTML5 从嵌套的 iframe 调整顶级文档 iframe 的大小

javascript - 需要 JQuery 帮助选择表行数组 (tr)

javascript - 如何在 Google App 脚本中将 <HTML> 解析为字符串?

looker-studio - Google Data Studio 中社区连接器配置的多个选项