Merged PR 4926: KPIs Refactor Stage 3 - Creates dedicated Churn model in KPIs
# Description Creates a new model in intermediate/kpis called `int_kpis__agg_monthly_churn_contribution`. This follows the convention (aggregated = by dimension and dimension value) and monthly (1 dimension value per dimension per date where date is unique in month). This single model aims to substitute, in the future, the 2 churn models simultaneously: * `int_monthly_12m_window_contribution_by_deal` * `int_monthly_churn_metrics` Main changes: * There's no longer a dependency with `int_monthly_aggregated_metrics_history_by_deal`. Rather, it gets the metrics and dimensions from wherever needed and nothing else. * I also took the opportunity to clean any code that was not needed after combining both models, resulting in dropping a whole CTE. * Updated schema description for clarification purposes. The output of the new model is identical to the 2nd model, `int_monthly_churn_metrics`, confirmed with the md5 trick. Model runs in 1.45 seconds in my laptop so no performance issue (it's technically faster than running the 2 current models which is around 6.3 seconds but whatever). Note that this has NO effect yet on production. The switch will be handled in a separated PR. # 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: #28948
This commit is contained in:
parent
0bf8cac41a
commit
e8a2fb1ae5
2 changed files with 313 additions and 0 deletions
|
|
@ -8624,3 +8624,80 @@ models:
|
|||
data_type: bigint
|
||||
description: The daily created bookings for a given date, dimension and value.
|
||||
|
||||
- name: int_kpis__agg_monthly_churn_contribution
|
||||
description: |
|
||||
This model calculates monthly churn contributions by dimension, dimension_value,
|
||||
and date. Unlike typical KPI models, it relies exclusively on monthly metrics
|
||||
computed at deal level and does not include data for the current month.
|
||||
|
||||
At its core, the model computes each deal's 12-month rolling contribution to global
|
||||
metrics. Afterwards, it aggregates these contributions for deals classified as
|
||||
'05-Churning' within the month. The output includes three churn-related contribution
|
||||
metrics, expressed as ratios over global totals:
|
||||
- total_revenue_churn_average_contribution
|
||||
- created_bookings_churn_average_contribution
|
||||
- listings_booked_in_month_churn_average_contribution
|
||||
Besides these 3 metrics, the actual total revenue churned in the month and the global
|
||||
total revenue windows are also included in the output. This is later used for YTD/MTD
|
||||
dedicated models, which only require it for Total Revenue.
|
||||
|
||||
These are calculated using an average contribution approach over the prior 12 months.
|
||||
If a deal has not been active for the full 12-month period, the average is still
|
||||
computed based on the number of months the deal has been active within that window.
|
||||
|
||||
Note: When analysing dimensions other than 'global', the metrics represent the additive
|
||||
share of churn relative to the global total. For example, if the total churn rate in a
|
||||
month is 10%, it may be broken down as 9% from the USA and 1% from GBR — still totaling 10%.
|
||||
|
||||
data_tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- date
|
||||
- dimension
|
||||
- dimension_value
|
||||
|
||||
columns:
|
||||
- name: date
|
||||
data_type: date
|
||||
description: The date for the month-to-date metrics.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: dimension
|
||||
data_type: string
|
||||
description: The dimension or granularity of the metrics.
|
||||
data_tests:
|
||||
- accepted_values:
|
||||
values:
|
||||
- global
|
||||
- by_number_of_listings
|
||||
- by_billing_country
|
||||
|
||||
- name: dimension_value
|
||||
data_type: string
|
||||
description: The value or segment available for the selected dimension.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: total_revenue_churn_preceding_12_months
|
||||
data_type: numeric
|
||||
description: |
|
||||
Total Revenue attributed to have churned considering the
|
||||
revenue generated by the deals in the 12 months period.
|
||||
|
||||
- name: total_revenue_global_preceding_12_months
|
||||
data_type: numeric
|
||||
description: |
|
||||
Total Revenue generated by all deals in the 12 months period.
|
||||
|
||||
- name: total_revenue_churn_average_contribution
|
||||
data_type: numeric
|
||||
description: Total Revenue churn rate (average approach).
|
||||
|
||||
- name: created_bookings_churn_average_contribution
|
||||
data_type: numeric
|
||||
description: Created Bookings churn rate (average approach).
|
||||
|
||||
- name: listings_booked_in_month_churn_average_contribution
|
||||
data_type: numeric
|
||||
description: Listings Booked in Month churn rate (average approach).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue