Create max_date view Change-Id: Ieeeaae6e2fa03c8deb998693de4b83b2244240b3
diff --git a/views/revenue/max_date.view.lkml b/views/revenue/max_date.view.lkml new file mode 100644 index 0000000..f25aefb --- /dev/null +++ b/views/revenue/max_date.view.lkml
@@ -0,0 +1,31 @@ + +view: max_date { + derived_table: { + sql: SELECT max_partition_date AS max_date_minus_2 + FROM `concord-test.stagingservice_gcc.gcc_revenue_latest_partition_view` + GROUP BY 1;; + } +########## PRIMARY KEYS ############ + dimension: pk { + description: "Primary key. This table should only ever have one row, so any dimension should be the primary key." + hidden: yes + primary_key: yes + sql: ${max_date_minus_2_raw} ;; + } +########## DIMENSIONS ############ + dimension_group: max_date_minus_2 { + description: "Calculates the latest date in the Revenue table and subtracts 2 days" + hidden: yes + type: time + datatype: date + timeframes: [raw, date, day_of_month, day_of_year, month, month_name, week] + sql: CAST(${TABLE}.max_date_minus_2 AS DATE) ;; + convert_tz: no + } + dimension: max_date_minus_2_day_of_quarter { + hidden: yes + description: "Day of quarter" + type: number + sql: DATE_DIFF(${max_date_minus_2_raw}, DATE_TRUNC(${max_date_minus_2_raw}, QUARTER), DAY) ;; + } +}