如何根据当前月份在Looker中命名列?

3

如何根据当前月份在Looker中命名列?

我有一个仪表板,显示当前月份和过去两个月的销售额。我希望这些列的名称是动态的,例如Sales_Sept,Sales_Aug和Sales_July。根据我们查看的月份,名称应相应地出现。

1个回答

1
你可以通过月份名称列进行轴旋转,以获得动态命名的列。
view: table_1 {
  derived_table: {
    sql: SELECT *
         FROM UNNEST(ARRAY<STRUCT<DATE DATE, A FLOAT64>>[
         ('2020-12-01', 10),
         ('2020-12-15', 30),
         ('2021-01-01', 30),
         ('2021-01-15', 60)])
       ;;
  }
  dimension_group: row {
    type: time
    datatype: date
    sql: ${TABLE}.date ;;
  }
  dimension: a {
    type: number
  }
  measure: total_a {
    type: sum
    sql: ${a} ;;
  }
}

explore: table_1 {}

按月份名称聚合:

Row totals for the last two months

按月份名称旋转:

Row totals as named columns by month


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接