How to name columns in Looker based on the current month?
I have a dashboard which shows sales for the current month and past two months. I want these columns to be dynamically named for eg Sales_Sept, Sales_Aug and Sales_July. Depending on the month we are looking at the names should appear accordingly
You can pivot by the month name column for dynamically named columns.
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 {}
Aggregate to month name:

Pivot by month name:

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With