From 6cc66bd170e663c2696c28593ab47d665197cfc6 Mon Sep 17 00:00:00 2001 From: "lightdash[bot]" <183517231+lightdash[bot]@users.noreply.github.com> Date: Mon, 15 Jun 2026 16:01:14 +0000 Subject: [PATCH] Add orders_per_customer_per_day metric to orders models MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Changes ### New metric: `orders_per_customer_per_day` Added to `order_id` column metrics in both `dbt_orders` and `dbt_orders_no_preagg`: - **Type:** `number` (custom SQL) - **SQL:** `SAFE_DIVIDE(COUNT(order_id), NULLIF(COUNT(DISTINCT user_id) * COUNT(DISTINCT DATE(order_date)), 0))` - **Label:** Orders per Customer per Day - **Format:** `0.000` - **Spotlight:** show, categories: verified, sales - **Purpose:** Normalizes order frequency by calendar days in the filtered period, making February comparable to longer months. ### Updated metric description: `count_distinct_user_id` Clarified in both files that `Unique Customers` counts customers who placed at least one order in the filtered period and is not a day-normalized or month-normalized metric — distinguishing it from the new `orders_per_customer_per_day`. ## Files changed - `dbt-bigquery/models/dbt_orders.yml` - `dbt-bigquery/models/dbt_orders_no_preagg.yml` Co-authored-by: lightdash[bot] <183517231+lightdash[bot]@users.noreply.github.com> Co-authored-by: Rohan Bedi --- dbt-bigquery/models/dbt_orders.yml | 13 ++++++++++++- dbt-bigquery/models/dbt_orders_no_preagg.yml | 13 ++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/dbt-bigquery/models/dbt_orders.yml b/dbt-bigquery/models/dbt_orders.yml index b5a06934..79789859 100644 --- a/dbt-bigquery/models/dbt_orders.yml +++ b/dbt-bigquery/models/dbt_orders.yml @@ -76,6 +76,17 @@ models: categories: - verified - sales + orders_per_customer_per_day: + type: number + sql: "SAFE_DIVIDE(COUNT(${TABLE}.order_id), NULLIF(COUNT(DISTINCT ${TABLE}.user_id) * COUNT(DISTINCT DATE(${order_date})), 0))" + label: 'Orders per Customer per Day' + description: 'Average number of orders per active customer per calendar day in the filtered period. This normalizes for shorter and longer months so February is comparable to January.' + format: '0.000' + spotlight: + visibility: show + categories: + - verified + - sales dimension: type: string - name: order_date @@ -351,7 +362,7 @@ models: count_distinct_user_id: type: count_distinct label: 'Unique Customers' - description: 'Number of unique customers who placed orders.' + description: 'Number of unique customers who placed at least one order in the filtered period. This is not a day-normalized or month-normalized metric.' spotlight: visibility: hide categories: diff --git a/dbt-bigquery/models/dbt_orders_no_preagg.yml b/dbt-bigquery/models/dbt_orders_no_preagg.yml index bce47444..e12dda54 100644 --- a/dbt-bigquery/models/dbt_orders_no_preagg.yml +++ b/dbt-bigquery/models/dbt_orders_no_preagg.yml @@ -48,6 +48,17 @@ models: categories: - verified - sales + orders_per_customer_per_day: + type: number + sql: "SAFE_DIVIDE(COUNT(${TABLE}.order_id), NULLIF(COUNT(DISTINCT ${TABLE}.user_id) * COUNT(DISTINCT DATE(${order_date})), 0))" + label: 'Orders per Customer per Day' + description: 'Average number of orders per active customer per calendar day in the filtered period. This normalizes for shorter and longer months so February is comparable to January.' + format: '0.000' + spotlight: + visibility: show + categories: + - verified + - sales dimension: type: string - name: order_date @@ -293,7 +304,7 @@ models: count_distinct_user_id: type: count_distinct label: 'Unique Customers' - description: 'Number of unique customers who placed orders.' + description: 'Number of unique customers who placed at least one order in the filtered period. This is not a day-normalized or month-normalized metric.' spotlight: visibility: hide categories: