Skip to content

Add orders_per_customer_per_day metric to orders models - #106

Open
lightdash[bot] wants to merge 1 commit into
mainfrom
lightdash-ai-writeback/f1d70ba5-fbe9-408f-aed2-bf67a625873a
Open

lightdash[bot] wants to merge 1 commit into
mainfrom
lightdash-ai-writeback/f1d70ba5-fbe9-408f-aed2-bf67a625873a

Conversation

@lightdash

@lightdash lightdash Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

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

## 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 <rohan@lightdash.com>
@lightdash

lightdash Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

🔍 Lightdash preview environment ready: https://analytics.lightdash.cloud/projects/547b34e3-75aa-4a1d-8e0f-ed63193de165/home

Compiled from branch lightdash-ai-writeback/f1d70ba5-fbe9-408f-aed2-bf67a625873a. Explores may take a minute to appear while the project compiles.

@github-actions

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

Lightdash Validation Results

Validating default project 8a223608-a1e4-426e-adcd-0598ea72b9f8

/opt/hostedtoolcache/Python/3.10.20/x64/lib/python3.10/site-packages/google/api_core/_python_version_support.py:255: FutureWarning: You are using a Python version (3.10.20) which Google will stop supporting in new releases of google.api_core once it reaches its end of life (2026-10-04). Please upgrade to the latest Python version, or at least Python 3.11, to continue receiving updates for google.api_core past that date.
  warnings.warn(message, FutureWarning)
/opt/hostedtoolcache/Python/3.10.20/x64/lib/python3.10/site-packages/google/api_core/_python_version_support.py:255: FutureWarning: You are using a Python version (3.10.20) which Google will stop supporting in new releases of google.cloud.dataproc_v1 once it reaches its end of life (2026-10-04). Please upgrade to the latest Python version, or at least Python 3.11, to continue receiving updates for google.cloud.dataproc_v1 past that date.
  warnings.warn(message, FutureWarning)

- SUCCESS> dbt_users 
- SUCCESS> dbt_orders 
- SUCCESS> dbt_baskets 
- SUCCESS> dbt_orders_no_preagg 
- SUCCESS> dbt_support_requests 

Compiled 5 explores, SUCCESS=5 ERRORS=0
-   Waiting for validation to finish
✖   Validation finished in 19s with 6 errors


- Tables: 0 errors
- Charts: 4 errors
- Dashboards: 2 errors


NAME                                                         LAST UPDATED BY   LAST UPDATED AT ERROR                                                                           
How do order volume and order values trend over time?        Jess Hitchcock      2026-05-13    Metric error: the field 'dbt_orders_median_revenue_per_order' no longer exists  
Partner Sales by Month - Last 12 Months                      Rohan Bedi          2026-06-11    Metric error: the field 'monthly_partner_info_total_sales' no longer exists     
with tc sql What is the median revenue per order by partner? João Viana          2026-04-30    Metric error: the field 'dbt_orders_median_revenue_per_order' no longer exists  
XLSX Export Test Table                                       Giorgi Bagdavadze   2026-06-09    Metric error: the field 'dbt_orders_median_revenue_per_order' no longer exists  
Sales Updates                                                Rohan Bedi          2026-06-11    The chart 'Partner Sales by Month - Last 12 Months' is broken on this dashboard.
XLSX Export Test Dashboard                                   Giorgi Bagdavadze   2026-06-09    The chart 'XLSX Export Test Table' is broken on this dashboard.                 

--> To see these errors in Lightdash, run lightdash preview

Note: 6 chart configuration warnings hidden. Use --show-chart-configuration-warnings to show.

This validation check is informational and does not block merging.

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.

0 participants