Skip to content

Conversation

@scholtzan
Copy link
Contributor

@scholtzan scholtzan commented Aug 29, 2025

https://mozilla-hub.atlassian.net/browse/DENG-8655

This PR adds period-over-period comparison functionality to metric-hub metric definitions, enabling users to compare current metrics with historical values across different time periods and granularities.

The period-over-period comparisons are available for all metric statistics with automatic time granularity adjustments and allow for different comparison types: previous values, absolute differences, and relative changes
It also does smart period conversion: 30-day periods automatically adjust to ~4 weeks, ~1 month, etc. based on selected time dimension

Configuration looks something like:

[metrics.any_content_engagement_clients.statistics.rolling_average]
aggregations = ["ratio", "sum"]
window_sizes = [28]
period_over_period = { periods = [365], kinds = ["previous", "relative_change"] }

Example: mozilla/metric-hub#1115

Creates measures like:

  • metric_sum_30_day_period_over_period_previous
  • metric_sum_30_day_period_over_period_difference
  • metric_rolling_average_sum_7_day_30_day_period_over_period_previous

Tested on https://mozilla.cloud.looker.com/dashboards/2540?Analysis+Period+%28with+Lookback%29=365+days (only work with looker-hub branch period-over-period-newtab-test)

Related docs: mozilla/data-docs#870

@dataops-ci-bot

This comment has been minimized.

@dataops-ci-bot

This comment has been minimized.

@scholtzan scholtzan marked this pull request as ready for review September 3, 2025 18:06
@dataops-ci-bot

This comment has been minimized.

@dataops-ci-bot
Copy link

Integration report for "Adjust period-over-period logic"

lookml.diff

Click to expand!
Only in /tmp/workspace/looker-hub/firefox_ios: dashboards
Only in /tmp/workspace/looker-hub/marketing: datagroups
Only in /tmp/workspace/generated-lookml/mdn_yari/datagroups: action_last_updated.datagroup.lkml
Only in /tmp/workspace/generated-lookml/mdn_yari/datagroups: deletion_request_last_updated.datagroup.lkml
Only in /tmp/workspace/generated-lookml/mdn_yari/datagroups: events_stream_table_last_updated.datagroup.lkml
Only in /tmp/workspace/generated-lookml/mdn_yari/explores: action.explore.lkml
Only in /tmp/workspace/generated-lookml/mdn_yari/explores: deletion_request.explore.lkml
Only in /tmp/workspace/generated-lookml/mdn_yari/explores: events_stream_table.explore.lkml
Only in /tmp/workspace/generated-lookml/mdn_yari/views: action.view.lkml
Only in /tmp/workspace/generated-lookml/mdn_yari/views: deletion_request.view.lkml
Only in /tmp/workspace/generated-lookml/mdn_yari/views: events_stream_table.view.lkml
Only in /tmp/workspace/looker-hub/search_private/datagroups: search_term_data_validation_reports_last_updated.datagroup.lkml
Only in /tmp/workspace/looker-hub/search_private/datagroups: search_term_sanitization_job_metadata_daily_last_updated.datagroup.lkml
Only in /tmp/workspace/looker-hub/: user_journey
diff -x '.*' -bur --no-dereference --new-file /tmp/workspace/looker-hub/ads/explores/metric_definitions_admarketplace.explore.lkml /tmp/workspace/generated-lookml/ads/explores/metric_definitions_admarketplace.explore.lkml
--- /tmp/workspace/looker-hub/ads/explores/metric_definitions_admarketplace.explore.lkml	2025-09-03 20:34:47.811617153 +0000
+++ /tmp/workspace/generated-lookml/ads/explores/metric_definitions_admarketplace.explore.lkml	2025-09-03 20:32:41.000000000 +0000
@@ -9,7 +9,6 @@
 explore: metric_definitions_admarketplace {
   always_filter: {
     filters: [
-      submission_date: "7 days",
       sampling: "1",
     ]
   }
diff -x '.*' -bur --no-dereference --new-file /tmp/workspace/looker-hub/ads/explores/metric_definitions_ad_metrics_daily.explore.lkml /tmp/workspace/generated-lookml/ads/explores/metric_definitions_ad_metrics_daily.explore.lkml
--- /tmp/workspace/looker-hub/ads/explores/metric_definitions_ad_metrics_daily.explore.lkml	2025-09-03 20:34:47.811617153 +0000
+++ /tmp/workspace/generated-lookml/ads/explores/metric_definitions_ad_metrics_daily.explore.lkml	2025-09-03 20:32:46.000000000 +0000
@@ -9,7 +9,6 @@
 explore: metric_definitions_ad_metrics_daily {
   always_filter: {
     filters: [
-      submission_date: "7 days",
       sampling: "1",
     ]
   }
diff -x '.*' -bur --no-dereference --new-file /tmp/workspace/looker-hub/ads/explores/metric_definitions_ad_mmm_metrics_daily.explore.lkml /tmp/workspace/generated-lookml/ads/explores/metric_definitions_ad_mmm_metrics_daily.explore.lkml
--- /tmp/workspace/looker-hub/ads/explores/metric_definitions_ad_mmm_metrics_daily.explore.lkml	2025-09-03 20:34:47.811617153 +0000
+++ /tmp/workspace/generated-lookml/ads/explores/metric_definitions_ad_mmm_metrics_daily.explore.lkml	2025-09-03 20:32:41.000000000 +0000
@@ -9,7 +9,6 @@
 explore: metric_definitions_ad_mmm_metrics_daily {
   always_filter: {
     filters: [
-      submission_date: "7 days",
       sampling: "1",
     ]
   }
diff -x '.*' -bur --no-dereference --new-file /tmp/workspace/looker-hub/ads/explores/metric_definitions_consolidated_ads_spocs.explore.lkml /tmp/workspace/generated-lookml/ads/explores/metric_definitions_consolidated_ads_spocs.explore.lkml
--- /tmp/workspace/looker-hub/ads/explores/metric_definitions_consolidated_ads_spocs.explore.lkml	2025-09-03 20:34:47.812617164 +0000
+++ /tmp/workspace/generated-lookml/ads/explores/metric_definitions_consolidated_ads_spocs.explore.lkml	2025-09-03 20:32:41.000000000 +0000
@@ -9,7 +9,6 @@
 explore: metric_definitions_consolidated_ads_spocs {
   always_filter: {
     filters: [
-      submission_date: "7 days",
       sampling: "1",
     ]
   }
diff -x '.*' -bur --no-dereference --new-file /tmp/workspace/looker-hub/ads/explores/metric_definitions_native_desktop_ad_metrics_by_position.explore.lkml /tmp/workspace/generated-lookml/ads/explores/metric_definitions_native_desktop_ad_metrics_by_position.explore.lkml
--- /tmp/workspace/looker-hub/ads/explores/metric_definitions_native_desktop_ad_metrics_by_position.explore.lkml	2025-09-03 20:34:47.812617164 +0000
+++ /tmp/workspace/generated-lookml/ads/explores/metric_definitions_native_desktop_ad_metrics_by_position.explore.lkml	2025-09-03 20:32:41.000000000 +0000
@@ -9,7 +9,6 @@
 explore: metric_definitions_native_desktop_ad_metrics_by_position {
   always_filter: {
     filters: [
-      submission_date: "7 days",
       sampling: "1",
     ]
   }
diff -x '.*' -bur --no-dereference --new-file /tmp/workspace/looker-hub/ads/explores/metric_definitions_native_desktop_ad_metrics.explore.lkml /tmp/workspace/generated-lookml/ads/explores/metric_definitions_native_desktop_ad_metrics.explore.lkml
--- /tmp/workspace/looker-hub/ads/explores/metric_definitions_native_desktop_ad_metrics.explore.lkml	2025-09-03 20:34:47.812617164 +0000
+++ /tmp/workspace/generated-lookml/ads/explores/metric_definitions_native_desktop_ad_metrics.explore.lkml	2025-09-03 20:32:41.000000000 +0000
@@ -9,7 +9,6 @@
 explore: metric_definitions_native_desktop_ad_metrics {
   always_filter: {
     filters: [
-      submission_date: "7 days",
       sampling: "1",
     ]
   }
diff -x '.*' -bur --no-dereference --new-file /tmp/workspace/looker-hub/ads/explores/metric_definitions_newtab_visit_duration.explore.lkml /tmp/workspace/generated-lookml/ads/explores/metric_definitions_newtab_visit_duration.explore.lkml
--- /tmp/workspace/looker-hub/ads/explores/metric_definitions_newtab_visit_duration.explore.lkml	2025-09-03 20:34:47.812617164 +0000
+++ /tmp/workspace/generated-lookml/ads/explores/metric_definitions_newtab_visit_duration.explore.lkml	2025-09-03 20:32:41.000000000 +0000
@@ -9,7 +9,6 @@
 explore: metric_definitions_newtab_visit_duration {
   always_filter: {
     filters: [
-      submission_date: "7 days",
       sampling: "1",
     ]
   }
diff -x '.*' -bur --no-dereference --new-file /tmp/workspace/looker-hub/ads/views/metric_definitions_admarketplace.view.lkml /tmp/workspace/generated-lookml/ads/views/metric_definitions_admarketplace.view.lkml
--- /tmp/workspace/looker-hub/ads/views/metric_definitions_admarketplace.view.lkml	2025-09-03 20:34:47.813617175 +0000
+++ /tmp/workspace/generated-lookml/ads/views/metric_definitions_admarketplace.view.lkml	2025-09-03 20:29:34.000000000 +0000
@@ -57,15 +57,33 @@
         
                     WHERE 
                     admarketplace.adm_date
+                    {% if _filters['analysis_period'] != "" %}
                     BETWEEN
+                    DATE_SUB(
+                        COALESCE(
+                            SAFE_CAST(
+                                {% date_start analysis_period %} AS DATE
+                            ), CURRENT_DATE()),
+                        INTERVAL {% parameter lookback_days %} DAY
+                    ) AND
+                    COALESCE(
+                        SAFE_CAST(
+                            {% date_end analysis_period %} AS DATE
+                        ), CURRENT_DATE())
+                    {% else %}
+                    BETWEEN
+                    DATE_SUB(
                     COALESCE(
                         SAFE_CAST(
                             {% date_start submission_date %} AS DATE
-                        ), CURRENT_DATE()) AND
+                            ), CURRENT_DATE()),
+                        INTERVAL {% parameter lookback_days %} DAY
+                    ) AND
                     COALESCE(
                         SAFE_CAST(
                             {% date_end submission_date %} AS DATE
                         ), CURRENT_DATE())
+                    {% endif %}
                 
                 )
             GROUP BY
@@ -133,8 +151,9 @@
 
   dimension_group: submission {
     type: time
+    datatype: date
     group_label: "Base Fields"
-    sql: CAST(${TABLE}.analysis_basis AS TIMESTAMP) ;;
+    sql: ${TABLE}.analysis_basis ;;
     label: "Submission"
     timeframes: [
       raw,
@@ -199,4 +218,24 @@
     default_value: "100"
     hidden: yes
   }
+
+  parameter: lookback_days {
+    label: "Lookback (Days)"
+    type: unquoted
+    description: "Number of days added before the filtered date range. Useful for period-over-period comparisons."
+    default_value: "0"
+  }
+
+  parameter: date_groupby_position {
+    label: "Date Group By Position"
+    type: unquoted
+    description: "Position of the date field in the group by clause. Required when submission_week, submission_month, submission_quarter, submission_year is selected as BigQuery can't correctly resolve the GROUP BY otherwise"
+    default_value: ""
+  }
+
+  filter: analysis_period {
+    type: date
+    label: "Analysis Period (with Lookback)"
+    description: "Use this filter to define the main analysis period. The results will include the selected date range plus any additional days specified by the 'Lookback days' setting."
+  }
 }
\ No newline at end of file
diff -x '.*' -bur --no-dereference --new-file /tmp/workspace/looker-hub/ads/views/metric_definitions_ad_mmm_metrics_daily.view.lkml /tmp/workspace/generated-lookml/ads/views/metric_definitions_ad_mmm_metrics_daily.view.lkml
--- /tmp/workspace/looker-hub/ads/views/metric_definitions_ad_mmm_metrics_daily.view.lkml	2025-09-03 20:34:47.813617175 +0000
+++ /tmp/workspace/generated-lookml/ads/views/metric_definitions_ad_mmm_metrics_daily.view.lkml	2025-09-03 20:29:34.000000000 +0000
@@ -80,15 +80,33 @@
         
                     WHERE 
                     ad_mmm_metrics_daily.submission_date
+                    {% if _filters['analysis_period'] != "" %}
                     BETWEEN
+                    DATE_SUB(
+                        COALESCE(
+                            SAFE_CAST(
+                                {% date_start analysis_period %} AS DATE
+                            ), CURRENT_DATE()),
+                        INTERVAL {% parameter lookback_days %} DAY
+                    ) AND
+                    COALESCE(
+                        SAFE_CAST(
+                            {% date_end analysis_period %} AS DATE
+                        ), CURRENT_DATE())
+                    {% else %}
+                    BETWEEN
+                    DATE_SUB(
                     COALESCE(
                         SAFE_CAST(
                             {% date_start submission_date %} AS DATE
-                        ), CURRENT_DATE()) AND
+                            ), CURRENT_DATE()),
+                        INTERVAL {% parameter lookback_days %} DAY
+                    ) AND
                     COALESCE(
                         SAFE_CAST(
                             {% date_end submission_date %} AS DATE
                         ), CURRENT_DATE())
+                    {% endif %}
                 
                 )
             GROUP BY
@@ -223,8 +241,9 @@
 
   dimension_group: submission {
     type: time
+    datatype: date
     group_label: "Base Fields"
-    sql: CAST(${TABLE}.analysis_basis AS TIMESTAMP) ;;
+    sql: ${TABLE}.analysis_basis ;;
     label: "Submission"
     timeframes: [
       raw,
@@ -358,4 +377,24 @@
     default_value: "100"
     hidden: yes
   }
+
+  parameter: lookback_days {
+    label: "Lookback (Days)"
+    type: unquoted
+    description: "Number of days added before the filtered date range. Useful for period-over-period comparisons."
+    default_value: "0"
+  }
+
+  parameter: date_groupby_position {
+    label: "Date Group By Position"
+    type: unquoted
+    description: "Position of the date field in the group by clause. Required when submission_week, submission_month, submission_quarter, submission_year is selected as BigQuery can't correctly resolve the GROUP BY otherwise"
+    default_value: ""
+  }
+
+  filter: analysis_period {
+    type: date
+    label: "Analysis Period (with Lookback)"
+    description: "Use this filter to define the main analysis period. The results will include the selected date range plus any additional days specified by the 'Lookback days' setting."
+  }
 }
\ No newline at end of file
diff -x '.*' -bur --no-dereference --new-file /tmp/workspace/looker-hub/ads/views/metric_definitions_consolidated_ads_spocs.view.lkml /tmp/workspace/generated-lookml/ads/views/metric_definitions_consolidated_ads_spocs.view.lkml
--- /tmp/workspace/looker-hub/ads/views/metric_definitions_consolidated_ads_spocs.view.lkml	2025-09-03 20:34:47.813617175 +0000
+++ /tmp/workspace/generated-lookml/ads/views/metric_definitions_consolidated_ads_spocs.view.lkml	2025-09-03 20:29:36.000000000 +0000
@@ -98,15 +98,33 @@
         
                     WHERE 
                     consolidated_ads_spocs.submission_date
+                    {% if _filters['analysis_period'] != "" %}
                     BETWEEN
+                    DATE_SUB(
+                        COALESCE(
+                            SAFE_CAST(
+                                {% date_start analysis_period %} AS DATE
+                            ), CURRENT_DATE()),
+                        INTERVAL {% parameter lookback_days %} DAY
+                    ) AND
+                    COALESCE(
+                        SAFE_CAST(
+                            {% date_end analysis_period %} AS DATE
+                        ), CURRENT_DATE())
+                    {% else %}
+                    BETWEEN
+                    DATE_SUB(
                     COALESCE(
                         SAFE_CAST(
                             {% date_start submission_date %} AS DATE
-                        ), CURRENT_DATE()) AND
+                            ), CURRENT_DATE()),
+                        INTERVAL {% parameter lookback_days %} DAY
+                    ) AND
                     COALESCE(
                         SAFE_CAST(
                             {% date_end submission_date %} AS DATE
                         ), CURRENT_DATE())
+                    {% endif %}
                 
                 )
             GROUP BY
@@ -230,8 +248,9 @@
 
   dimension_group: submission {
     type: time
+    datatype: date
     group_label: "Base Fields"
-    sql: CAST(${TABLE}.analysis_basis AS TIMESTAMP) ;;
+    sql: ${TABLE}.analysis_basis ;;
     label: "Submission"
     timeframes: [
       raw,
@@ -328,4 +347,24 @@
     default_value: "100"
     hidden: yes
   }
+
+  parameter: lookback_days {
+    label: "Lookback (Days)"
+    type: unquoted
+    description: "Number of days added before the filtered date range. Useful for period-over-period comparisons."
+    default_value: "0"
+  }
+
+  parameter: date_groupby_position {
+    label: "Date Group By Position"
+    type: unquoted
+    description: "Position of the date field in the group by clause. Required when submission_week, submission_month, submission_quarter, submission_year is selected as BigQuery can't correctly resolve the GROUP BY otherwise"
+    default_value: ""
+  }
+
+  filter: analysis_period {
+    type: date
+    label: "Analysis Period (with Lookback)"
+    description: "Use this filter to define the main analysis period. The results will include the selected date range plus any additional days specified by the 'Lookback days' setting."
+  }
 }
\ No newline at end of file
diff -x '.*' -bur --no-dereference --new-file /tmp/workspace/looker-hub/ads/views/metric_definitions_newtab_visit_duration.view.lkml /tmp/workspace/generated-lookml/ads/views/metric_definitions_newtab_visit_duration.view.lkml
--- /tmp/workspace/looker-hub/ads/views/metric_definitions_newtab_visit_duration.view.lkml	2025-09-03 20:34:47.814617185 +0000
+++ /tmp/workspace/generated-lookml/ads/views/metric_definitions_newtab_visit_duration.view.lkml	2025-09-03 20:29:39.000000000 +0000
@@ -64,15 +64,33 @@
         
                     WHERE 
                     newtab_visit_duration.week
+                    {% if _filters['analysis_period'] != "" %}
                     BETWEEN
+                    DATE_SUB(
+                        COALESCE(
+                            SAFE_CAST(
+                                {% date_start analysis_period %} AS DATE
+                            ), CURRENT_DATE()),
+                        INTERVAL {% parameter lookback_days %} DAY
+                    ) AND
+                    COALESCE(
+                        SAFE_CAST(
+                            {% date_end analysis_period %} AS DATE
+                        ), CURRENT_DATE())
+                    {% else %}
+                    BETWEEN
+                    DATE_SUB(
                     COALESCE(
                         SAFE_CAST(
                             {% date_start submission_date %} AS DATE
-                        ), CURRENT_DATE()) AND
+                            ), CURRENT_DATE()),
+                        INTERVAL {% parameter lookback_days %} DAY
+                    ) AND
                     COALESCE(
                         SAFE_CAST(
                             {% date_end submission_date %} AS DATE
                         ), CURRENT_DATE())
+                    {% endif %}
                 
                 )
             GROUP BY
@@ -149,8 +167,9 @@
 
   dimension_group: submission {
     type: time
+    datatype: date
     group_label: "Base Fields"
-    sql: CAST(${TABLE}.analysis_basis AS TIMESTAMP) ;;
+    sql: ${TABLE}.analysis_basis ;;
     label: "Submission"
     timeframes: [
       raw,
@@ -225,4 +244,24 @@
     default_value: "100"
     hidden: yes
   }
+
+  parameter: lookback_days {
+    label: "Lookback (Days)"
+    type: unquoted
+    description: "Number of days added before the filtered date range. Useful for period-over-period comparisons."
+    default_value: "0"
+  }
+
+  parameter: date_groupby_position {
+    label: "Date Group By Position"
+    type: unquoted
+    description: "Position of the date field in the group by clause. Required when submission_week, submission_month, submission_quarter, submission_year is selected as BigQuery can't correctly resolve the GROUP BY otherwise"
+    default_value: ""
+  }
+
+  filter: analysis_period {
+    type: date
+    label: "Analysis Period (with Lookback)"
+    description: "Use this filter to define the main analysis period. The results will include the selected date range plus any additional days specified by the 'Lookback days' setting."
+  }
 }
\ No newline at end of file
diff -x '.*' -bur --no-dereference --new-file /tmp/workspace/looker-hub/fenix/explores/metric_definitions_baseline.explore.lkml /tmp/workspace/generated-lookml/fenix/explores/metric_definitions_baseline.explore.lkml
--- /tmp/workspace/looker-hub/fenix/explores/metric_definitions_baseline.explore.lkml	2025-09-03 20:34:47.856617633 +0000
+++ /tmp/workspace/generated-lookml/fenix/explores/metric_definitions_baseline.explore.lkml	2025-09-03 20:32:47.000000000 +0000
@@ -9,7 +9,6 @@
 explore: metric_definitions_baseline {
   always_filter: {
     filters: [
-      submission_date: "7 days",
       sampling: "1",
     ]
   }
diff -x '.*' -bur --no-dereference --new-file /tmp/workspace/looker-hub/fenix/explores/metric_definitions_baseline_v2.explore.lkml /tmp/workspace/generated-lookml/fenix/explores/metric_definitions_baseline_v2.explore.lkml
--- /tmp/workspace/looker-hub/fenix/explores/metric_definitions_baseline_v2.explore.lkml	2025-09-03 20:34:47.857617643 +0000
+++ /tmp/workspace/generated-lookml/fenix/explores/metric_definitions_baseline_v2.explore.lkml	2025-09-03 20:32:47.000000000 +0000
@@ -9,7 +9,6 @@
 explore: metric_definitions_baseline_v2 {
   always_filter: {
     filters: [
-      submission_date: "7 days",
       sampling: "1",
     ]
   }
diff -x '.*' -bur --no-dereference --new-file /tmp/workspace/looker-hub/fenix/explores/metric_definitions_events.explore.lkml /tmp/workspace/generated-lookml/fenix/explores/metric_definitions_events.explore.lkml
--- /tmp/workspace/looker-hub/fenix/explores/metric_definitions_events.explore.lkml	2025-09-03 20:34:47.857617643 +0000
+++ /tmp/workspace/generated-lookml/fenix/explores/metric_definitions_events.explore.lkml	2025-09-03 20:32:41.000000000 +0000
@@ -9,7 +9,6 @@
 explore: metric_definitions_events {
   always_filter: {
     filters: [
-      submission_date: "7 days",
       sampling: "1",
     ]
   }
diff -x '.*' -bur --no-dereference --new-file /tmp/workspace/looker-hub/fenix/explores/metric_definitions_feature_usage_metrics_v1.explore.lkml /tmp/workspace/generated-lookml/fenix/explores/metric_definitions_feature_usage_metrics_v1.explore.lkml
--- /tmp/workspace/looker-hub/fenix/explores/metric_definitions_feature_usage_metrics_v1.explore.lkml	2025-09-03 20:34:47.857617643 +0000
+++ /tmp/workspace/generated-lookml/fenix/explores/metric_definitions_feature_usage_metrics_v1.explore.lkml	2025-09-03 20:32:41.000000000 +0000
@@ -9,7 +9,6 @@
 explore: metric_definitions_feature_usage_metrics_v1 {
   always_filter: {
     filters: [
-      submission_date: "7 days",
       sampling: "1",
     ]
   }
diff -x '.*' -bur --no-dereference --new-file /tmp/workspace/looker-hub/fenix/explores/metric_definitions_fenix_active_users_aggregates_view.explore.lkml /tmp/workspace/generated-lookml/fenix/explores/metric_definitions_fenix_active_users_aggregates_view.explore.lkml
--- /tmp/workspace/looker-hub/fenix/explores/metric_definitions_fenix_active_users_aggregates_view.explore.lkml	2025-09-03 20:34:47.857617643 +0000
+++ /tmp/workspace/generated-lookml/fenix/explores/metric_definitions_fenix_active_users_aggregates_view.explore.lkml	2025-09-03 20:32:41.000000000 +0000
@@ -9,7 +9,6 @@
 explore: metric_definitions_fenix_active_users_aggregates_view {
   always_filter: {
     filters: [
-      submission_date: "7 days",
       sampling: "1",
     ]
   }
diff -x '.*' -bur --no-dereference --new-file /tmp/workspace/looker-hub/fenix/explores/metric_definitions_fenix_active_users_view.explore.lkml /tmp/workspace/generated-lookml/fenix/explores/metric_definitions_fenix_active_users_view.explore.lkml
--- /tmp/workspace/looker-hub/fenix/explores/metric_definitions_fenix_active_users_view.explore.lkml	2025-09-03 20:34:47.857617643 +0000
+++ /tmp/workspace/generated-lookml/fenix/explores/metric_definitions_fenix_active_users_view.explore.lkml	2025-09-03 20:32:41.000000000 +0000
@@ -9,7 +9,6 @@
 explore: metric_definitions_fenix_active_users_view {
   always_filter: {
     filters: [
-      submission_date: "7 days",
       sampling: "1",
     ]
   }
diff -x '.*' -bur --no-dereference --new-file /tmp/workspace/looker-hub/fenix/explores/metric_definitions_fenix_engagement_view.explore.lkml /tmp/workspace/generated-lookml/fenix/explores/metric_definitions_fenix_engagement_view.explore.lkml
--- /tmp/workspace/looker-hub/fenix/explores/metric_definitions_fenix_engagement_view.explore.lkml	2025-09-03 20:34:47.857617643 +0000
+++ /tmp/workspace/generated-lookml/fenix/explores/metric_definitions_fenix_engagement_view.explore.lkml	2025-09-03 20:32:41.000000000 +0000
@@ -9,7 +9,6 @@
 explore: metric_definitions_fenix_engagement_view {
   always_filter: {
     filters: [
-      submission_date: "7 days",
       sampling: "1",
     ]
   }
diff -x '.*' -bur --no-dereference --new-file /tmp/workspace/looker-hub/fenix/explores/metric_definitions_fenix_retention_view.explore.lkml /tmp/workspace/generated-lookml/fenix/explores/metric_definitions_fenix_retention_view.explore.lkml
--- /tmp/workspace/looker-hub/fenix/explores/metric_definitions_fenix_retention_view.explore.lkml	2025-09-03 20:34:47.857617643 +0000
+++ /tmp/workspace/generated-lookml/fenix/explores/metric_definitions_fenix_retention_view.explore.lkml	2025-09-03 20:32:41.000000000 +0000
@@ -9,7 +9,6 @@
 explore: metric_definitions_fenix_retention_view {
   always_filter: {
     filters: [
-      submission_date: "7 days",
       sampling: "1",
     ]
   }
diff -x '.*' -bur --no-dereference --new-file /tmp/workspace/looker-hub/fenix/explores/metric_definitions_metrics.explore.lkml /tmp/workspace/generated-lookml/fenix/explores/metric_definitions_metrics.explore.lkml
--- /tmp/workspace/looker-hub/fenix/explores/metric_definitions_metrics.explore.lkml	2025-09-03 20:34:47.857617643 +0000
+++ /tmp/workspace/generated-lookml/fenix/explores/metric_definitions_metrics.explore.lkml	2025-09-03 20:32:41.000000000 +0000
@@ -9,7 +9,6 @@
 explore: metric_definitions_metrics {
   always_filter: {
     filters: [
-      submission_date: "7 days",
       sampling: "1",
     ]
   }
diff -x '.*' -bur --no-dereference --new-file /tmp/workspace/looker-hub/fenix/explores/metric_definitions_mobile_search_clients_engines_sources_daily.explore.lkml /tmp/workspace/generated-lookml/fenix/explores/metric_definitions_mobile_search_clients_engines_sources_daily.explore.lkml
--- /tmp/workspace/looker-hub/fenix/explores/metric_definitions_mobile_search_clients_engines_sources_daily.explore.lkml	2025-09-03 20:34:47.857617643 +0000
+++ /tmp/workspace/generated-lookml/fenix/explores/metric_definitions_mobile_search_clients_engines_sources_daily.explore.lkml	2025-09-03 20:32:41.000000000 +0000
@@ -9,7 +9,6 @@
 explore: metric_definitions_mobile_search_clients_engines_sources_daily {
   always_filter: {
     filters: [
-      submission_date: "7 days",
       sampling: "1",
     ]
   }
diff -x '.*' -bur --no-dereference --new-file /tmp/workspace/looker-hub/fenix/explores/metric_definitions_new_profile_activation.explore.lkml /tmp/workspace/generated-lookml/fenix/explores/metric_definitions_new_profile_activation.explore.lkml
--- /tmp/workspace/looker-hub/fenix/explores/metric_definitions_new_profile_activation.explore.lkml	2025-09-03 20:34:47.857617643 +0000
+++ /tmp/workspace/generated-lookml/fenix/explores/metric_definitions_new_profile_activation.explore.lkml	2025-09-03 20:32:41.000000000 +0000
@@ -9,7 +9,6 @@
 explore: metric_definitions_new_profile_activation {
   always_filter: {
     filters: [
-      submission_date: "7 days",
       sampling: "1",
     ]
   }
diff -x '.*' -bur --no-dereference --new-file /tmp/workspace/looker-hub/fenix/explores/metric_definitions_special_onboarding_events_v2.explore.lkml /tmp/workspace/generated-lookml/fenix/explores/metric_definitions_special_onboarding_events_v2.explore.lkml
--- /tmp/workspace/looker-hub/fenix/explores/metric_definitions_special_onboarding_events_v2.explore.lkml	2025-09-03 20:34:47.857617643 +0000
+++ /tmp/workspace/generated-lookml/fenix/explores/metric_definitions_special_onboarding_events_v2.explore.lkml	2025-09-03 20:32:41.000000000 +0000
@@ -9,7 +9,6 @@
 explore: metric_definitions_special_onboarding_events_v2 {
   always_filter: {
     filters: [
-      submission_date: "7 days",
       sampling: "1",
     ]
   }
diff -x '.*' -bur --no-dereference --new-file /tmp/workspace/looker-hub/fenix/views/metric_definitions_baseline_v2.view.lkml /tmp/workspace/generated-lookml/fenix/views/metric_definitions_baseline_v2.view.lkml
--- /tmp/workspace/looker-hub/fenix/views/metric_definitions_baseline_v2.view.lkml	2025-09-03 20:34:47.895618048 +0000
+++ /tmp/workspace/generated-lookml/fenix/views/metric_definitions_baseline_v2.view.lkml	2025-09-03 20:31:34.000000000 +0000
@@ -194,26 +194,62 @@
                 
                     WHERE 
                     baseline_v2.submission_date
+                    {% if _filters['analysis_period'] != "" %}
                     BETWEEN
+                    DATE_SUB(
+                        COALESCE(
+                            SAFE_CAST(
+                                {% date_start analysis_period %} AS DATE
+                            ), CURRENT_DATE()),
+                        INTERVAL {% parameter lookback_days %} DAY
+                    ) AND
+                    COALESCE(
+                        SAFE_CAST(
+                            {% date_end analysis_period %} AS DATE
+                        ), CURRENT_DATE())
+                    {% else %}
+                    BETWEEN
+                    DATE_SUB(
                     COALESCE(
                         SAFE_CAST(
                             {% date_start submission_date %} AS DATE
-                        ), CURRENT_DATE()) AND
+                            ), CURRENT_DATE()),
+                        INTERVAL {% parameter lookback_days %} DAY
+                    ) AND
                     COALESCE(
                         SAFE_CAST(
                             {% date_end submission_date %} AS DATE
                         ), CURRENT_DATE())
+                    {% endif %}
                  AND 
                     looker_base_fields.submission_date
+                    {% if _filters['analysis_period'] != "" %}
+                    BETWEEN
+                    DATE_SUB(
+                        COALESCE(
+                            SAFE_CAST(
+                                {% date_start analysis_period %} AS DATE
+                            ), CURRENT_DATE()),
+                        INTERVAL {% parameter lookback_days %} DAY
+                    ) AND
+                    COALESCE(
+                        SAFE_CAST(
+                            {% date_end analysis_period %} AS DATE
+                        ), CURRENT_DATE())
+                    {% else %}
                     BETWEEN
+                    DATE_SUB(
                     COALESCE(
                         SAFE_CAST(
                             {% date_start submission_date %} AS DATE
-                        ), CURRENT_DATE()) AND
+                            ), CURRENT_DATE()),
+                        INTERVAL {% parameter lookback_days %} DAY
+                    ) AND
                     COALESCE(
                         SAFE_CAST(
                             {% date_end submission_date %} AS DATE
                         ), CURRENT_DATE())
+                    {% endif %}
                 
                     AND
                         looker_base_fields.sample_id < {% parameter sampling %}
@@ -792,8 +828,9 @@
 
   dimension_group: submission {
     type: time
+    datatype: date
     group_label: "Base Fields"
-    sql: CAST(${TABLE}.analysis_basis AS TIMESTAMP) ;;
+    sql: ${TABLE}.analysis_basis ;;
     label: "Submission"
     timeframes: [
       raw,
@@ -868,4 +905,24 @@
     default_value: "100"
     hidden: no
   }
+
+  parameter: lookback_days {
+    label: "Lookback (Days)"
+    type: unquoted
+    description: "Number of days added before the filtered date range. Useful for period-over-period comparisons."
+    default_value: "0"
+  }
+
+  parameter: date_groupby_position {
+    label: "Date Group By Position"
+    type: unquoted
+    description: "Position of the date field in the group by clause. Required when submission_week, submission_month, submission_quarter, submission_year is selected as BigQuery can't correctly resolve the GROUP BY otherwise"
+    default_value: ""
+  }
+
+  filter: analysis_period {
+    type: date
+    label: "Analysis Period (with Lookback)"
+    description: "Use this filter to define the main analysis period. The results will include the selected date range plus any additional days specified by the 'Lookback days' setting."
+  }
 }
\ No newline at end of file
diff -x '.*' -bur --no-dereference --new-file /tmp/workspace/looker-hub/fenix/views/metric_definitions_baseline.view.lkml /tmp/workspace/generated-lookml/fenix/views/metric_definitions_baseline.view.lkml
--- /tmp/workspace/looker-hub/fenix/views/metric_definitions_baseline.view.lkml	2025-09-03 20:34:47.895618048 +0000
+++ /tmp/workspace/generated-lookml/fenix/views/metric_definitions_baseline.view.lkml	2025-09-03 20:31:32.000000000 +0000
@@ -193,26 +193,62 @@
                 
                     WHERE 
                     baseline.submission_date
+                    {% if _filters['analysis_period'] != "" %}
                     BETWEEN
+                    DATE_SUB(
+                        COALESCE(
+                            SAFE_CAST(
+                                {% date_start analysis_period %} AS DATE
+                            ), CURRENT_DATE()),
+                        INTERVAL {% parameter lookback_days %} DAY
+                    ) AND
+                    COALESCE(
+                        SAFE_CAST(
+                            {% date_end analysis_period %} AS DATE
+                        ), CURRENT_DATE())
+                    {% else %}
+                    BETWEEN
+                    DATE_SUB(
                     COALESCE(
                         SAFE_CAST(
                             {% date_start submission_date %} AS DATE
-                        ), CURRENT_DATE()) AND
+                            ), CURRENT_DATE()),
+                        INTERVAL {% parameter lookback_days %} DAY
+                    ) AND
                     COALESCE(
                         SAFE_CAST(
                             {% date_end submission_date %} AS DATE
                         ), CURRENT_DATE())
+                    {% endif %}
                  AND 
                     looker_base_fields.submission_date
+                    {% if _filters['analysis_period'] != "" %}
+                    BETWEEN
+                    DATE_SUB(
+                        COALESCE(
+                            SAFE_CAST(
+                                {% date_start analysis_period %} AS DATE
+                            ), CURRENT_DATE()),
+                        INTERVAL {% parameter lookback_days %} DAY
+                    ) AND
+                    COALESCE(
+                        SAFE_CAST(
+                            {% date_end analysis_period %} AS DATE
+                        ), CURRENT_DATE())
+                    {% else %}
                     BETWEEN
+                    DATE_SUB(
                     COALESCE(
                         SAFE_CAST(
                             {% date_start submission_date %} AS DATE
-                        ), CURRENT_DATE()) AND
+                            ), CURRENT_DATE()),
+                        INTERVAL {% parameter lookback_days %} DAY
+                    ) AND
                     COALESCE(
                         SAFE_CAST(
                             {% date_end submission_date %} AS DATE
                         ), CURRENT_DATE())
+                    {% endif %}
                 
                     AND
                         looker_base_fields.sample_id < {% parameter sampling %}
@@ -782,8 +818,9 @@
 
   dimension_group: submission {
     type: time
+    datatype: date
     group_label: "Base Fields"
-    sql: CAST(${TABLE}.analysis_basis AS TIMESTAMP) ;;
+    sql: ${TABLE}.analysis_basis ;;
     label: "Submission"
     timeframes: [
       raw,
@@ -882,4 +919,24 @@
     default_value: "100"
     hidden: no
   }
+
+  parameter: lookback_days {
+    label: "Lookback (Days)"
+    type: unquoted
+    description: "Number of days added before the filtered date range. Useful for period-over-period comparisons."
+    default_value: "0"
+  }
+
+  parameter: date_groupby_position {
+    label: "Date Group By Position"
+    type: unquoted
+    description: "Position of the date field in the group by clause. Required when submission_week, submission_month, submission_quarter, submission_year is selected as BigQuery can't correctly resolve the GROUP BY otherwise"
+    default_value: ""
+  }
+
+  filter: analysis_period {
+    type: date
+    label: "Analysis Period (with Lookback)"
+    description: "Use this filter to define the main analysis period. The results will include the selected date range plus any additional days specified by the 'Lookback days' setting."
+  }
 }
\ No newline at end of file
diff -x '.*' -bur --no-dereference --new-file /tmp/workspace/looker-hub/fenix/views/metric_definitions_events.view.lkml /tmp/workspace/generated-lookml/fenix/views/metric_definitions_events.view.lkml
--- /tmp/workspace/looker-hub/fenix/views/metric_definitions_events.view.lkml	2025-09-03 20:34:47.895618048 +0000
+++ /tmp/workspace/generated-lookml/fenix/views/metric_definitions_events.view.lkml	2025-09-03 20:31:35.000000000 +0000
@@ -210,26 +210,62 @@
                 
                     WHERE 
                     events.submission_date
+                    {% if _filters['analysis_period'] != "" %}
                     BETWEEN
+                    DATE_SUB(
+                        COALESCE(
+                            SAFE_CAST(
+                                {% date_start analysis_period %} AS DATE
+                            ), CURRENT_DATE()),
+                        INTERVAL {% parameter lookback_days %} DAY
+                    ) AND
+                    COALESCE(
+                        SAFE_CAST(
+                            {% date_end analysis_period %} AS DATE
+                        ), CURRENT_DATE())
+                    {% else %}
+                    BETWEEN
+                    DATE_SUB(
                     COALESCE(
                         SAFE_CAST(
                             {% date_start submission_date %} AS DATE
-                        ), CURRENT_DATE()) AND
+                            ), CURRENT_DATE()),
+                        INTERVAL {% parameter lookback_days %} DAY
+                    ) AND
                     COALESCE(
                         SAFE_CAST(
                             {% date_end submission_date %} AS DATE
                         ), CURRENT_DATE())
+                    {% endif %}
                  AND 
                     looker_base_fields.submission_date
+                    {% if _filters['analysis_period'] != "" %}
+                    BETWEEN
+                    DATE_SUB(
+                        COALESCE(
+                            SAFE_CAST(
+                                {% date_start analysis_period %} AS DATE
+                            ), CURRENT_DATE()),
+                        INTERVAL {% parameter lookback_days %} DAY
+                    ) AND
+                    COALESCE(
+                        SAFE_CAST(
+                            {% date_end analysis_period %} AS DATE
+                        ), CURRENT_DATE())
+                    {% else %}
                     BETWEEN
+                    DATE_SUB(
                     COALESCE(
                         SAFE_CAST(
                             {% date_start submission_date %} AS DATE
-                        ), CURRENT_DATE()) AND
+                            ), CURRENT_DATE()),
+                        INTERVAL {% parameter lookback_days %} DAY
+                    ) AND
                     COALESCE(
                         SAFE_CAST(
                             {% date_end submission_date %} AS DATE
                         ), CURRENT_DATE())
+                    {% endif %}
                 
                     AND
                         looker_base_fields.sample_id < {% parameter sampling %}
@@ -799,8 +835,9 @@
 
   dimension_group: submission {
     type: time
+    datatype: date
     group_label: "Base Fields"
-    sql: CAST(${TABLE}.analysis_basis AS TIMESTAMP) ;;
+    sql: ${TABLE}.analysis_basis ;;
     label: "Submission"
     timeframes: [
       raw,
@@ -881,4 +918,24 @@
     default_value: "100"
     hidden: no
   }
+
+  parameter: lookback_days {
+    label: "Lookback (Days)"
+    type: unquoted
+    description: "Number of days added before the filtered date range. Useful for period-over-period comparisons."
+    default_value: "0"
+  }
+
+  parameter: date_groupby_position {
+    label: "Date Group By Position"
+    type: unquoted
+    description: "Position of the date field in the group by clause. Required when submission_week, submission_month, submission_quarter, submission_year is selected as BigQuery can't correctly resolve the GROUP BY otherwise"
+    default_value: ""
+  }
+
+  filter: analysis_period {
+    type: date
+    label: "Analysis Period (with Lookback)"
+    description: "Use this filter to define the main analysis period. The results will include the selected date range plus any additional days specified by the 'Lookback days' setting."
+  }
 }
\ No newline at end of file
diff -x '.*' -bur --no-dereference --new-file /tmp/workspace/looker-hub/fenix/views/metric_definitions_feature_usage_metrics_v1.view.lkml /tmp/workspace/generated-lookml/fenix/views/metric_definitions_feature_usage_metrics_v1.view.lkml
--- /tmp/workspace/looker-hub/fenix/views/metric_definitions_feature_usage_metrics_v1.view.lkml	2025-09-03 20:34:47.896618059 +0000
+++ /tmp/workspace/generated-lookml/fenix/views/metric_definitions_feature_usage_metrics_v1.view.lkml	2025-09-03 20:31:37.000000000 +0000
@@ -213,15 +213,33 @@
         
                     WHERE 
                     feature_usage_metrics_v1.submission_date
+                    {% if _filters['analysis_period'] != "" %}
                     BETWEEN
+                    DATE_SUB(
+                        COALESCE(
+                            SAFE_CAST(
+                                {% date_start analysis_period %} AS DATE
+                            ), CURRENT_DATE()),
+                        INTERVAL {% parameter lookback_days %} DAY
+                    ) AND
+                    COALESCE(
+                        SAFE_CAST(
+                            {% date_end analysis_period %} AS DATE
+                        ), CURRENT_DATE())
+                    {% else %}
+                    BETWEEN
+                    DATE_SUB(
                     COALESCE(
                         SAFE_CAST(
                             {% date_start submission_date %} AS DATE
-                        ), CURRENT_DATE()) AND
+                            ), CURRENT_DATE()),
+                        INTERVAL {% parameter lookback_days %} DAY
+                    ) AND
                     COALESCE(
                         SAFE_CAST(
                             {% date_end submission_date %} AS DATE
                         ), CURRENT_DATE())
+                    {% endif %}
                 
                 )
             GROUP BY
@@ -851,8 +869,9 @@
 
   dimension_group: submission {
     type: time
+    datatype: date
     group_label: "Base Fields"
-    sql: CAST(${TABLE}.analysis_basis AS TIMESTAMP) ;;
+    sql: ${TABLE}.analysis_basis ;;
     label: "Submission"
     timeframes: [
       raw,
@@ -1022,4 +1041,24 @@
     default_value: "100"
     hidden: yes
   }
+
+  parameter: lookback_days {
+    label: "Lookback (Days)"
+    type: unquoted
+    description: "Number of days added before the filtered date range. Useful for period-over-period comparisons."
+    default_value: "0"
+  }
+
+  parameter: date_groupby_position {
+    label: "Date Group By Position"
+    type: unquoted
+    description: "Position of the date field in the group by clause. Required when submission_week, submission_month, submission_quarter, submission_year is selected as BigQuery can't correctly resolve the GROUP BY otherwise"
+    default_value: ""
+  }
+
+  filter: analysis_period {
+    type: date
+    label: "Analysis Period (with Lookback)"
+    description: "Use this filter to define the main analysis period. The results will include the selected date range plus any additional days specified by the 'Lookback days' setting."
+  }
 }
\ No newline at end of file
diff -x '.*' -bur --no-dereference --new-file /tmp/workspace/looker-hub/fenix/views/metric_definitions_fenix_active_users_aggregates_view.view.lkml /tmp/workspace/generated-lookml/fenix/views/metric_definitions_fenix_active_users_aggregates_view.view.lkml
--- /tmp/workspace/looker-hub/fenix/views/metric_definitions_fenix_active_users_aggregates_view.view.lkml	2025-09-03 20:34:47.896618059 +0000
+++ /tmp/workspace/generated-lookml/fenix/views/metric_definitions_fenix_active_users_aggregates_view.view.lkml	2025-09-03 20:31:40.000000000 +0000
@@ -224,26 +224,62 @@
         
                     WHERE 
                     fenix_active_users_aggregates_view.submission_date
+                    {% if _filters['analysis_period'] != "" %}
                     BETWEEN
+                    DATE_SUB(
+                        COALESCE(
+                            SAFE_CAST(
+                                {% date_start analysis_period %} AS DATE
+                            ), CURRENT_DATE()),
+                        INTERVAL {% parameter lookback_days %} DAY
+                    ) AND
+                    COALESCE(
+                        SAFE_CAST(
+                            {% date_end analysis_period %} AS DATE
+                        ), CURRENT_DATE())
+                    {% else %}
+                    BETWEEN
+                    DATE_SUB(
                     COALESCE(
                         SAFE_CAST(
                             {% date_start submission_date %} AS DATE
-                        ), CURRENT_DATE()) AND
+                            ), CURRENT_DATE()),
+                        INTERVAL {% parameter lookback_days %} DAY
+                    ) AND
                     COALESCE(
                         SAFE_CAST(
                             {% date_end submission_date %} AS DATE
                         ), CURRENT_DATE())
+                    {% endif %}
                  AND 
                     looker_base_fields.submission_date
+                    {% if _filters['analysis_period'] != "" %}
+                    BETWEEN
+                    DATE_SUB(
+                        COALESCE(
+                            SAFE_CAST(
+                                {% date_start analysis_period %} AS DATE
+                            ), CURRENT_DATE()),
+                        INTERVAL {% parameter lookback_days %} DAY
+                    ) AND
+                    COALESCE(
+                        SAFE_CAST(
+                            {% date_end analysis_period %} AS DATE
+                        ), CURRENT_DATE())
+                    {% else %}
                     BETWEEN
+                    DATE_SUB(
                     COALESCE(
                         SAFE_CAST(
                             {% date_start submission_date %} AS DATE
-                        ), CURRENT_DATE()) AND
+                            ), CURRENT_DATE()),
+                        INTERVAL {% parameter lookback_days %} DAY
+                    ) AND
                     COALESCE(
                         SAFE_CAST(
                             {% date_end submission_date %} AS DATE
                         ), CURRENT_DATE())
+                    {% endif %}
                 
                     AND
                         looker_base_fields.sample_id < {% parameter sampling %}
@@ -1023,8 +1059,9 @@
 
   dimension_group: submission {
     type: time
+    datatype: date
     group_label: "Base Fields"
-    sql: CAST(${TABLE}.analysis_basis AS TIMESTAMP) ;;
+    sql: ${TABLE}.analysis_basis ;;
     label: "Submission"
     timeframes: [
       raw,
@@ -1099,4 +1136,24 @@
     default_value: "100"
     hidden: no
   }
+
+  parameter: lookback_days {
+    label: "Lookback (Days)"
+    type: unquoted
+    description: "Number of days added before the filtered date range. Useful for period-over-period comparisons."
+    default_value: "0"
+  }
+
+  parameter: date_groupby_position {
+    label: "Date Group By Position"
+    type: unquoted
+    description: "Position of the date field in the group by clause. Required when submission_week, submission_month, submission_quarter, submission_year is selected as BigQuery can't correctly resolve the GROUP BY otherwise"
+    default_value: ""
+  }
+
+  filter: analysis_period {
+    type: date
+    label: "Analysis Period (with Lookback)"
+    description: "Use this filter to define the main analysis period. The results will include the selected date range plus any additional days specified by the 'Lookback days' setting."
+  }
 }
\ No newline at end of file
diff -x '.*' -bur --no-dereference --new-file /tmp/workspace/looker-hub/fenix/views/metric_definitions_fenix_active_users_view.view.lkml /tmp/workspace/generated-lookml/fenix/views/metric_definitions_fenix_active_users_view.view.lkml
--- /tmp/workspace/looker-hub/fenix/views/metric_definitions_fenix_active_users_view.view.lkml	2025-09-03 20:34:47.896618059 +0000
+++ /tmp/workspace/generated-lookml/fenix/views/metric_definitions_fenix_active_users_view.view.lkml	2025-09-03 20:29:05.000000000 +0000
@@ -188,26 +188,62 @@
                 
                     WHERE 
                     fenix_active_users_view.submission_date
+                    {% if _filters['analysis_period'] != "" %}
                     BETWEEN
+                    DATE_SUB(
+                        COALESCE(
+                            SAFE_CAST(
+                                {% date_start analysis_period %} AS DATE
+                            ), CURRENT_DATE()),
+                        INTERVAL {% parameter lookback_days %} DAY
+                    ) AND
+                    COALESCE(
+                        SAFE_CAST(
+                            {% date_end analysis_period %} AS DATE
+                        ), CURRENT_DATE())
+                    {% else %}
+                    BETWEEN
+                    DATE_SUB(
                     COALESCE(
                         SAFE_CAST(
                             {% date_start submission_date %} AS DATE
-                        ), CURRENT_DATE()) AND
+                            ), CURRENT_DATE()),
+                        INTERVAL {% parameter lookback_days %} DAY
+                    ) AND
                     COALESCE(
                         SAFE_CAST(
                             {% date_end submission_date %} AS DATE
                         ), CURRENT_DATE())
+                    {% endif %}
                  AND 
                     looker_base_fields.submission_date
+                    {% if _filters['analysis_period'] != "" %}
+                    BETWEEN
+                    DATE_SUB(
+                        COALESCE(
+                            SAFE_CAST(
+                                {% date_start analysis_period %} AS DATE
+                            ), CURRENT_DATE()),
+                        INTERVAL {% parameter lookback_days %} DAY
+                    ) AND
+                    COALESCE(
+                        SAFE_CAST(
+                            {% date_end analysis_period %} AS DATE
+                        ), CURRENT_DATE())
+                    {% else %}
                     BETWEEN
+                    DATE_SUB(
                     COALESCE(
                         SAFE_CAST(
                             {% date_start submission_date %} AS DATE
-                        ), CURRENT_DATE()) AND
+                            ), CURRENT_DATE()),
+                        INTERVAL {% parameter lookback_days %} DAY
+                    ) AND
                     COALESCE(
                         SAFE_CAST(
                             {% date_end submission_date %} AS DATE
                         ), CURRENT_DATE())
+                    {% endif %}
                 
                     AND
                         looker_base_fields.sample_id < {% parameter sampling %}
@@ -750,8 +786,9 @@
 
   dimension_group: submission {
     type: time
+    datatype: date
     group_label: "Base Fields"
-    sql: CAST(${TABLE}.analysis_basis AS TIMESTAMP) ;;
+    sql: ${TABLE}.analysis_basis ;;
     label: "Submission"
     timeframes: [
       raw,
@@ -826,4 +863,24 @@
     default_value: "100"
     hidden: no
   }
+
+  parameter: lookback_days {
+    label: "Lookback (Days)"
+    type: unquoted
+    description: "Number of days added before the filtered date range. Useful for period-over-period comparisons."
+    default_value: "0"
+  }
+
+  parameter: date_groupby_position {
+    label: "Date Group By Position"
+    type: unquoted
+    description: "Position of the date field in the group by clause. Required when submission_week, submission_month, submission_quarter, submission_year is selected as BigQuery can't correctly resolve the GROUP BY otherwise"
+    default_value: ""
+  }
+
+  filter: analysis_period {
+    type: date
+    label: "Analysis Period (with Lookback)"
+    description: "Use this filter to define the main analysis period. The results will include the selected date range plus any additional days specified by the 'Lookback days' setting."
+  }
 }
\ No newline at end of file
diff -x '.*' -bur --no-dereference --new-file /tmp/workspace/looker-hub/fenix/views/metric_definitions_fenix_engagement_view.view.lkml /tmp/workspace/generated-lookml/fenix/views/metric_definitions_fenix_engagement_view.view.lkml
--- /tmp/workspace/looker-hub/fenix/views/metric_definitions_fenix_engagement_view.view.lkml	2025-09-03 20:34:47.896618059 +0000
+++ /tmp/workspace/generated-lookml/fenix/views/metric_definitions_fenix_engagement_view.view.lkml	2025-09-03 20:29:08.000000000 +0000
@@ -212,26 +212,62 @@
         
                     WHERE 
                     fenix_engagement_view.submission_date
+                    {% if _filters['analysis_period'] != "" %}
                     BETWEEN
+                    DATE_SUB(
+                        COALESCE(
+                            SAFE_CAST(
+                                {% date_start analysis_period %} AS DATE
+                            ), CURRENT_DATE()),
+                        INTERVAL {% parameter lookback_days %} DAY
+                    ) AND
+                    COALESCE(
+                        SAFE_CAST(
+                            {% date_end analysis_period %} AS DATE
+                        ), CURRENT_DATE())
+                    {% else %}
+                    BETWEEN
+                    DATE_SUB(
                     COALESCE(
                         SAFE_CAST(
                             {% date_start submission_date %} AS DATE
-                        ), CURRENT_DATE()) AND
+                            ), CURRENT_DATE()),
+                        INTERVAL {% parameter lookback_days %} DAY
+                    ) AND
                     COALESCE(
                         SAFE_CAST(
                             {% date_end submission_date %} AS DATE
                         ), CURRENT_DATE())
+                    {% endif %}
                  AND 
                     looker_base_fields.submission_date
+                    {% if _filters['analysis_period'] != "" %}
                     BETWEEN
+                    DATE_SUB(
+                        COALESCE(
+                            SAFE_CAST(
+                                {% date_start analysis_period %} AS DATE
+                            ), CURRENT_DATE()),
+                        INTERVAL {% parameter lookback_days %} DAY
+                    ) AND
+                    COALESCE(
+                        SAFE_CAST(
+                            {% date_end analysis_period %} AS DATE
+                        ), CURRENT_DATE())
+                    {% else %}
+                    BETWEEN
+                    DATE_SUB(
                     COALESCE(
                         SAFE_CAST(
                             {% date_start submission_date %} AS DATE
-                        ), CURRENT_DATE()) AND
+                            ), CURRENT_DATE()),
+                        INTERVAL {% parameter lookback_days %} DAY
+                    ) AND
                     COALESCE(
                         SAFE_CAST(
                             {% date_end submission_date %} AS DATE
                         ), CURRENT_DATE())
+                    {% endif %}
                 
                     AND
                         looker_base_fields.sample_id < {% parameter sampling %}
@@ -951,8 +987,9 @@
 
   dimension_group: submission {
     type: time
+    datatype: date
     group_label: "Base Fields"
-    sql: CAST(${TABLE}.analysis_basis AS TIMESTAMP) ;;
+    sql: ${TABLE}.analysis_basis ;;
     label: "Submission"
     timeframes: [
       raw,
@@ -1044,4 +1081,24 @@
     default_value: "100"
     hidden: no
   }
+
+  parameter: lookback_days {
+    label: "Lookback (Days)"
+    type: unquoted
+    description: "Number of days added before the filtered date range. Useful for period-over-period comparisons."
+    default_value: "0"
+  }
+
+  parameter: date_groupby_position {
+    label: "Date Group By Position"
+    type: unquoted
+    description: "Position of the date field in the group by clause. Required when submission_week, submission_month, submission_quarter, submission_year is selected as BigQuery can't correctly resolve the GROUP BY otherwise"
+    default_value: ""
+  }
+
+  filter: analysis_period {
+    type: date
+    label: "Analysis Period (with Lookback)"
+    description: "Use this filter to define the main analysis period. The results will include the selected date range plus any additional days specified by the 'Lookback days' setting."
+  }
 }
\ No newline at end of file
diff -x '.*' -bur --no-dereference --new-file /tmp/workspace/looker-hub/fenix/views/metric_definitions_fenix_retention_view.view.lkml /tmp/workspace/generated-lookml/fenix/views/metric_definitions_fenix_retention_view.view.lkml
--- /tmp/workspace/looker-hub/fenix/views/metric_definitions_fenix_retention_view.view.lkml	2025-09-03 20:34:47.896618059 +0000
+++ /tmp/workspace/generated-lookml/fenix/views/metric_definitions_fenix_retention_view.view.lkml	2025-09-03 20:29:10.000000000 +0000
@@ -223,26 +223,62 @@
         
                     WHERE 
                     fenix_retention_view.metric_date
+                    {% if _filters['analysis_period'] != "" %}
                     BETWEEN
+                    DATE_SUB(
+                        COALESCE(
+                            SAFE_CAST(
+                                {% date_start analysis_period %} AS DATE
+                            ), CURRENT_DATE()),
+                        INTERVAL {% parameter lookback_days %} DAY
+                    ) AND
+                    COALESCE(
+                        SAFE_CAST(
+                            {% date_end analysis_period %} AS DATE
+                        ), CURRENT_DATE())
+                    {% else %}
+                    BETWEEN
+                    DATE_SUB(
                     COALESCE(
                         SAFE_CAST(
                             {% date_start submission_date %} AS DATE
-                        ), CURRENT_DATE()) AND
+                            ), CURRENT_DATE()),
+                        INTERVAL {% parameter lookback_days %} DAY
+                    ) AND
                     COALESCE(
                         SAFE_CAST(
                             {% date_end submission_date %} AS DATE
                         ), CURRENT_DATE())
+                    {% endif %}
                  AND 
                     looker_base_fields.submission_date
+                    {% if _filters['analysis_period'] != "" %}
                     BETWEEN
+                    DATE_SUB(
+                        COALESCE(
+                            SAFE_CAST(
+                                {% date_start analysis_period %} AS DATE
+                            ), CURRENT_DATE()),
+                        INTERVAL {% parameter lookback_days %} DAY
+                    ) AND
+                    COALESCE(
+                        SAFE_CAST(
+                            {% date_end analysis_period %} AS DATE
+                        ), CURRENT_DATE())
+                    {% else %}
+                    BETWEEN
+                    DATE_SUB(
                     COALESCE(
                         SAFE_CAST(
                             {% date_start submission_date %} AS DATE
-                        ), CURRENT_DATE()) AND
+                            ), CURRENT_DATE()),
+                        INTERVAL {% parameter lookback_days %} DAY
+                    ) AND
                     COALESCE(
                         SAFE_CAST(
                             {% date_end submission_date %} AS DATE
                         ), CURRENT_DATE())
+                    {% endif %}
                 
                     AND
                         looker_base_fields.sample_id < {% parameter sampling %}
@@ -1003,8 +1039,9 @@
 
   dimension_group: submission {
     type: time
+    datatype: date
     group_label: "Base Fields"
-    sql: CAST(${TABLE}.analysis_basis AS TIMESTAMP) ;;
+    sql: ${TABLE}.analysis_basis ;;
     label: "Submission"
     timeframes: [
       raw,
@@ -1113,4 +1150,24 @@
     default_value: "100"
     hidden: no
   }
+
+  parameter: lookback_days {
+    label: "Lookback (Days)"
+    type: unquoted
+    description: "Number of days added before the filtered date range. Useful for period-over-period comparisons."
+    default_value: "0"
+  }
+
+  parameter: date_groupby_position {
+    label: "Date Group By Position"
+    type: unquoted
+    description: "Position of the date field in the group by clause. Required when submission_week, submission_month, submission_quarter, submission_year is selected as BigQuery can't correctly resolve the GROUP BY otherwise"
+    default_value: ""
+  }
+
+  filter: analysis_period {
+    type: date
+    label: "Analysis Period (with Lookback)"
+    description: "Use this filter to define the main analysis period. The results will include the selected date range plus any additional days specified by the 'Lookback days' setting."
+  }
 }
\ No newline at end of file
diff -x '.*' -bur --no-dereference --new-file /tmp/workspace/looker-hub/fenix/views/metric_definitions_metrics.view.lkml /tmp/workspace/generated-lookml/fenix/views/metric_definitions_metrics.view.lkml
--- /tmp/workspace/looker-hub/fenix/views/metric_definitions_metrics.view.lkml	2025-09-03 20:34:47.896618059 +0000
+++ /tmp/workspace/generated-lookml/fenix/views/metric_definitions_metrics.view.lkml	2025-09-03 20:29:12.000000000 +0000
@@ -194,26 +194,62 @@
                 
                     WHERE 
                     metrics.submission_date
+                    {% if _filters['analysis_period'] != "" %}
                     BETWEEN
+                    DATE_SUB(
+                        COALESCE(
+                            SAFE_CAST(
+                                {% date_start analysis_period %} AS DATE
+                            ), CURRENT_DATE()),
+                        INTERVAL {% parameter lookback_days %} DAY
+                    ) AND
+                    COALESCE(
+                        SAFE_CAST(
+                            {% date_end analysis_period %} AS DATE
+                        ), CURRENT_DATE())
+                    {% else %}
+                    BETWEEN
+                    DATE_SUB(
                     COALESCE(
                         SAFE_CAST(
                             {% date_start submission_date %} AS DATE
-                        ), CURRENT_DATE()) AND
+                            ), CURRENT_DATE()),
+                        INTERVAL {% parameter lookback_days %} DAY
+                    ) AND
                     COALESCE(
                         SAFE_CAST(
                             {% date_end submission_date %} AS DATE
                         ), CURRENT_DATE())
+                    {% endif %}
                  AND 
                     looker_base_fields.submission_date
+                    {% if _filters['analysis_period'] != "" %}
+                    BETWEEN
+                    DATE_SUB(
+                        COALESCE(
+                            SAFE_CAST(
+                                {% date_start analysis_period %} AS DATE
+                            ), CURRENT_DATE()),
+                        INTERVAL {% parameter lookback_days %} DAY
+                    ) AND
+                    COALESCE(
+                        SAFE_CAST(
+                            {% date_end analysis_period %} AS DATE
+                        ), CURRENT_DATE())
+                    {% else %}
                     BETWEEN
+                    DATE_SUB(
                     COALESCE(
                         SAFE_CAST(
                             {% date_start submission_date %} AS DATE
-                        ), CURRENT_DATE()) AND
+                            ), CURRENT_DATE()),
+                        INTERVAL {% parameter lookback_days %} DAY
+                    ) AND
                     COALESCE(
                         SAFE_CAST(
                             {% date_end submission_date %} AS DATE
                         ), CURRENT_DATE())
+                    {% endif %}
                 
                     AND
                         looker_base_fields.sample_id < {% parameter sampling %}
@@ -767,8 +803,9 @@
 
   dimension_group: submission {
     type: time
+    datatype: date
     group_label: "Base Fields"
-    sql: CAST(${TABLE}.analysis_basis AS TIMESTAMP) ;;
+    sql: ${TABLE}.analysis_basis ;;
     label: "Submission"
     timeframes: [
       raw,
@@ -843,4 +880,24 @@
     default_value: "100"
     hidden: no
   }
+
+  parameter: lookback_days {
+ 

⚠️ Only part of the diff is displayed.

Link to full diff

@scholtzan scholtzan added this pull request to the merge queue Sep 4, 2025
Merged via the queue into main with commit cc72096 Sep 4, 2025
7 checks passed
@scholtzan scholtzan deleted the period-over-period-support branch September 4, 2025 16:51
scholtzan added a commit that referenced this pull request Sep 4, 2025
scholtzan added a commit that referenced this pull request Sep 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants