forked from dbt-labs/jaffle-shop-classic
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9978716
commit 92c98a9
Showing
4 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
version: 2 | ||
|
||
exposures: | ||
- name: customer_lifetime_returns_value_dashboard | ||
label: Customer lifetime returns value dashboard | ||
description: A dashboard for the lifetime value (total amount) of returns from each customer. | ||
type: dashboard | ||
url: https://prod-apnortheast-a.online.tableau.com/#/site/octopusenergyjapan/home/customerlifetimereturns | ||
owner: | ||
email: "[email protected]" | ||
depends_on: | ||
- ref('fnl_finance_customerlifetimereturns') | ||
|
||
models: | ||
- name: fnl_finance_customerlifetimereturns | ||
meta: | ||
owner: "[email protected]" | ||
team_owner: '!subteam^S02GPV1135F' #@dbt_gatekeepers | ||
description: | | ||
Table with the total sales for each customer. | ||
columns: | ||
- name: customer_id | ||
description: Unique customer id. | ||
tests: | ||
- unique | ||
- not_null | ||
- name: customer_lifetime_returns | ||
description: Total value of all orders returned by customer. |
6 changes: 6 additions & 0 deletions
6
jaffle_shop/models/final/finance/fnl_finance_customerlifetimereturns.sql
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
SELECT | ||
customer_id | ||
, SUM(amount) as customer_lifetime_returns | ||
FROM {{ ref('wh_orders') }} | ||
WHERE status = 'returned' | ||
GROUP BY customer_id |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
version: 2 | ||
|
||
exposures: | ||
- name: new_customers_dashboard | ||
label: Montlhly new customers dashboard | ||
description: A dashboard for the number of new customers making first orders each month. | ||
type: dashboard | ||
url: https://prod-apnortheast-a.online.tableau.com/#/site/octopusenergyjapan/home/monthlynewcustomers | ||
owner: | ||
email: "[email protected]" | ||
depends_on: | ||
- ref('fnl_sales_newcustomers') | ||
|
||
models: | ||
- name: fnl_sales_newcustomers | ||
meta: | ||
owner: "[email protected]" | ||
team_owner: '!subteam^S02GPV1135F' #@dbt_gatekeepers | ||
description: | | ||
Count of new customers (i.e. ones making their first order) each month. | ||
columns: | ||
- name: year_month | ||
description: Year and month. | ||
tests: | ||
- unique | ||
- not_null | ||
- name: new_customers | ||
description: Number of new customers making first orders that month. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
WITH customer_first_orders AS ( | ||
SELECT | ||
DATE_TRUNC('MONTH', first_order) AS year_month | ||
FROM {{ ref('wh_customers') }} | ||
WHERE first_order IS NOT NULL | ||
) | ||
|
||
SELECT | ||
year_month | ||
, COUNT(1) AS new_customers | ||
FROM customer_first_orders | ||
GROUP BY year_month |