Add orders_per_customer_per_day metric to orders models - #106
Open
lightdash[bot] wants to merge 1 commit into
Open
lightdash[bot] wants to merge 1 commit into
lightdash[bot] wants to merge 1 commit into
Conversation
## 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>
Contributor
Author
|
🔍 Lightdash preview environment ready: https://analytics.lightdash.cloud/projects/547b34e3-75aa-4a1d-8e0f-ed63193de165/home Compiled from branch |
Lightdash Validation Results
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
New metric:
orders_per_customer_per_dayAdded to
order_idcolumn metrics in bothdbt_ordersanddbt_orders_no_preagg:number(custom SQL)SAFE_DIVIDE(COUNT(order_id), NULLIF(COUNT(DISTINCT user_id) * COUNT(DISTINCT DATE(order_date)), 0))0.000Updated metric description:
count_distinct_user_idClarified in both files that
Unique Customerscounts 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 neworders_per_customer_per_day.Files changed
dbt-bigquery/models/dbt_orders.ymldbt-bigquery/models/dbt_orders_no_preagg.yml