Merged PR 3279: Remove unused code: additive contribution to churn and its metrics
# Description Simplifies the code for the models: * int_monthly_12m_window_contribution_by_deal * int_monthly_churn_metrics By just removing the additive contribution approach. This also reduces the schema file information of these 2 models. I also adapted the description to clarify the state of the models. No rush to merge this. # Checklist - [X] The edited models and dependants run properly with production data. - [X] The edited models are sufficiently documented. - [X] The edited models contain PK tests, and I've ran and passed them. - [X] I have checked for DRY opportunities with other models and docs. - [X] I've picked the right materialization for the affected models. # Other - [ ] Check if a full-refresh is required after this PR is merged. Related work items: #22691
This commit is contained in:
parent
689ea53c11
commit
5c1f6f88f2
3 changed files with 5 additions and 132 deletions
|
|
@ -42,24 +42,6 @@ with
|
|||
when ambd.preceding_months_count_by_deal < 12 then true else false
|
||||
end as has_deal_been_created_less_than_12_months_ago,
|
||||
|
||||
-- ADDITIVE APPROACH --
|
||||
-- 12 months window sum of metrics
|
||||
ambd.sum_total_revenue_preceding_12_months,
|
||||
ambd.sum_created_bookings_preceding_12_months,
|
||||
ambd.sum_listings_booked_in_month_preceding_12_months,
|
||||
|
||||
-- Global amounts by sum of the 12 months window sum of metric on a given
|
||||
-- date
|
||||
sum(ambd.sum_total_revenue_preceding_12_months) over (
|
||||
partition by ambd.date
|
||||
) as global_total_revenue_preceding_12_months,
|
||||
sum(ambd.sum_created_bookings_preceding_12_months) over (
|
||||
partition by ambd.date
|
||||
) as global_created_bookings_preceding_12_months,
|
||||
sum(ambd.sum_listings_booked_in_month_preceding_12_months) over (
|
||||
partition by ambd.date
|
||||
) as global_listings_booked_in_month_preceding_12_months,
|
||||
|
||||
-- AVERAGE APPROACH --
|
||||
-- 12 months window sum of metric divided by amount of active months per
|
||||
-- deal
|
||||
|
|
@ -101,24 +83,6 @@ select
|
|||
-- Amount of active months per deal used in the computation
|
||||
preceding_months_count_by_deal,
|
||||
|
||||
-- ADDITIVE APPROACH --
|
||||
-- 12 months window sum of metrics
|
||||
coalesce(
|
||||
sum_total_revenue_preceding_12_months
|
||||
/ nullif(global_total_revenue_preceding_12_months, 0),
|
||||
0
|
||||
) as total_revenue_12m_additive_contribution,
|
||||
coalesce(
|
||||
sum_created_bookings_preceding_12_months
|
||||
/ nullif(global_created_bookings_preceding_12_months, 0),
|
||||
0
|
||||
) as created_bookings_12m_additive_contribution,
|
||||
coalesce(
|
||||
sum_listings_booked_in_month_preceding_12_months
|
||||
/ nullif(global_listings_booked_in_month_preceding_12_months, 0),
|
||||
0
|
||||
) as listings_booked_in_month_12m_additive_contribution,
|
||||
|
||||
-- AVERAGE APPROACH --
|
||||
-- 12 months window sum of metric divided by amount of active months per deal
|
||||
coalesce(
|
||||
|
|
|
|||
|
|
@ -19,27 +19,6 @@ with
|
|||
m12wc.date,
|
||||
{{ dimension.dimension }} as dimension,
|
||||
{{ dimension.dimension_value }} as dimension_value,
|
||||
sum(
|
||||
case
|
||||
when m12wc.deal_lifecycle_state in {{ churn_lifecycle_states }}
|
||||
then m12wc.total_revenue_12m_additive_contribution
|
||||
else 0
|
||||
end
|
||||
) as total_revenue_churn_additive_contribution,
|
||||
sum(
|
||||
case
|
||||
when m12wc.deal_lifecycle_state in {{ churn_lifecycle_states }}
|
||||
then m12wc.created_bookings_12m_additive_contribution
|
||||
else 0
|
||||
end
|
||||
) as created_bookings_churn_additive_contribution,
|
||||
sum(
|
||||
case
|
||||
when m12wc.deal_lifecycle_state in {{ churn_lifecycle_states }}
|
||||
then m12wc.listings_booked_in_month_12m_additive_contribution
|
||||
else 0
|
||||
end
|
||||
) as listings_booked_in_month_churn_additive_contribution,
|
||||
sum(
|
||||
case
|
||||
when m12wc.deal_lifecycle_state in {{ churn_lifecycle_states }}
|
||||
|
|
@ -90,15 +69,6 @@ select
|
|||
d.dimension_value,
|
||||
d.is_end_of_month,
|
||||
d.is_current_month,
|
||||
cast(
|
||||
c.total_revenue_churn_additive_contribution as numeric(19, 6)
|
||||
) as total_revenue_churn_additive_contribution,
|
||||
cast(
|
||||
c.created_bookings_churn_additive_contribution as numeric(19, 6)
|
||||
) as created_bookings_churn_additive_contribution,
|
||||
cast(
|
||||
c.listings_booked_in_month_churn_additive_contribution as numeric(19, 6)
|
||||
) as listings_booked_in_month_churn_additive_contribution,
|
||||
cast(
|
||||
c.total_revenue_churn_average_contribution as numeric(19, 6)
|
||||
) as total_revenue_churn_average_contribution,
|
||||
|
|
|
|||
|
|
@ -1249,26 +1249,13 @@ models:
|
|||
- created_bookings
|
||||
- listings_booked_in_month
|
||||
|
||||
There's 2 different contribution methods, the additive and
|
||||
the average approach. The additive approach will "penalise"
|
||||
accounts that have been active for less than 12 months on the
|
||||
contribution amount, while the average approach "boosts" the
|
||||
contribution of those accounts that have been active for less
|
||||
than 12 months.
|
||||
|
||||
Mathematically speaking, it is encouraged to use the additive
|
||||
approach ;-)
|
||||
|
||||
Find below the details of the computation:
|
||||
- Additive approach:
|
||||
Over a period of 12 months, sum the value of a given a metric
|
||||
for each deal. Sum all the deals to get a global. Divide the
|
||||
deal value vs. the global one.
|
||||
- Average approach:
|
||||
The contribution is based on an Average approach:
|
||||
Over a period of 12 months, sum the value of a given a metric
|
||||
for each deal, and divide it by the amount of months we're considering
|
||||
for that deal. Sum all the average amounts per deals to get a global.
|
||||
Divide the avg per deal value vs. the sum of avgs global one.
|
||||
The average approach "boosts" the contribution of those accounts
|
||||
that have been active for less than 12 months.
|
||||
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
|
|
@ -1322,42 +1309,6 @@ models:
|
|||
preceding_months_count_by_deal, and will be true on the first
|
||||
year of deal activity.
|
||||
|
||||
- name: total_revenue_12m_additive_contribution
|
||||
data_type: numeric
|
||||
description: |
|
||||
Share of the deal contribution on total revenue
|
||||
vs. the global amount, on the preceding 12 months
|
||||
with respect to date. It uses the additive approach.
|
||||
It can be negative.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: created_bookings_12m_additive_contribution
|
||||
data_type: numeric
|
||||
description: |
|
||||
Share of the deal contribution on created bookings
|
||||
vs. the global amount, on the preceding 12 months
|
||||
with respect to date. It uses the additive approach.
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
max_value: 1
|
||||
strictly: false
|
||||
|
||||
- name: listings_booked_in_month_12m_additive_contribution
|
||||
data_type: numeric
|
||||
description: |
|
||||
Share of the deal contribution on listings booked in month
|
||||
vs. the global amount, on the preceding 12 months
|
||||
with respect to date. It uses the additive approach.
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
max_value: 1
|
||||
strictly: false
|
||||
|
||||
- name: total_revenue_12m_average_contribution
|
||||
data_type: numeric
|
||||
description: |
|
||||
|
|
@ -1407,11 +1358,11 @@ models:
|
|||
This model retrieves the 12 month contribution to global metrics
|
||||
by deal and aggregates it to dimension and dimension value for those
|
||||
deals that are tagged as '05-Churning' in that month. Thus, it provides
|
||||
a total of 6 churn related metrics, represented as ratios over the total:
|
||||
a total of 3 churn related metrics, represented as ratios over the total:
|
||||
- Total Revenue (in GBP)
|
||||
- Created Bookings
|
||||
- Listings Booked in Month
|
||||
In two ways of computing the contribution, Additive and Average. For further
|
||||
by using the Average contribution method. For further
|
||||
information, please refer to the documentation of the model:
|
||||
- int_monthly_12m_window_contribution_by_deal
|
||||
|
||||
|
|
@ -1450,18 +1401,6 @@ models:
|
|||
tests:
|
||||
- not_null
|
||||
|
||||
- name: total_revenue_churn_additive_contribution
|
||||
data_type: numeric
|
||||
description: Total Revenue churn rate (additive approach).
|
||||
|
||||
- name: created_bookings_churn_additive_contribution
|
||||
data_type: numeric
|
||||
description: Created Bookings churn rate (additive approach).
|
||||
|
||||
- name: listings_booked_in_month_churn_additive_contribution
|
||||
data_type: numeric
|
||||
description: Listings Booked in Month churn rate (additive approach).
|
||||
|
||||
- name: total_revenue_churn_average_contribution
|
||||
data_type: numeric
|
||||
description: Total Revenue churn rate (average approach).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue