Merged PR 4493: Adds Revenue Churn Rate in YTD/MTD Overview

# Description

Changes:
* Adds Revenue Churn Rate in YTD/MTD Overview. This has several implications, I finally understood how to properly compute a YTD.

The problem is that Revenue Churn Rate is a % of the Total "Churned" Revenue in a 12 m period vs. the Total Revenue in the same 12 m period. This is a bit tricky because it's not really additive, because of the Churn definition. Total Churned Revenue is the Revenue that the churned deals in a month generated on that past 12 months prior to churning.

So - in order to aggregate it properly, we need to do the sum of the Total Churned Revenue and retrieve the Total Revenue on these 12 months, and THEN compute the Churn rate.

This PR mainly retrieves the necessary input from the Churn models and then follows a similar computation as for the rest of YTD/MTD converted metrics.

I'll handle Onboarding MRR in a separated PR as this one is quite dense already.

# 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: #27609, #27805
This commit is contained in:
Oriol Roqué Paniagua 2025-02-25 09:41:28 +00:00
parent 78d42462a8
commit a6671ee4d0
7 changed files with 446 additions and 89 deletions

View file

@ -36,6 +36,10 @@ with
churning_deals as current_month_mtd_churning_deals,
live_deals as current_month_mtd_live_deals,
waiver_payments_in_gbp as current_month_mtd_waiver_payments_in_gbp,
total_revenue_churn_preceding_12_months
as current_month_mtd_total_revenue_churn_12m,
total_revenue_global_preceding_12_months
as current_month_mtd_total_revenue_global_12m,
-- Previous Year (12 months ago), Month To Date Metrics --
previous_year_total_revenue_in_gbp
@ -58,6 +62,10 @@ with
previous_year_live_deals as previous_year_mtd_live_deals,
previous_year_waiver_payments_in_gbp
as previous_year_mtd_waiver_payments_in_gbp,
previous_year_total_revenue_churn_preceding_12_months
as previous_year_mtd_total_revenue_churn_12m,
previous_year_total_revenue_global_preceding_12_months
as previous_year_mtd_total_revenue_global_12m,
-- Previous Month, End Of Month Metrics --
lag(total_revenue_in_gbp) over (
@ -95,7 +103,13 @@ with
) as previous_month_eom_live_deals,
lag(waiver_payments_in_gbp) over (
partition by dimension, dimension_value order by date
) as previous_month_eom_waiver_payments_in_gbp
) as previous_month_eom_waiver_payments_in_gbp,
lag(total_revenue_churn_preceding_12_months) over (
partition by dimension, dimension_value order by date
) as previous_month_eom_total_revenue_churn_12m,
lag(total_revenue_global_preceding_12_months) over (
partition by dimension, dimension_value order by date
) as previous_month_eom_total_revenue_global_12m
from int_mtd_vs_previous_year_metrics
where
@ -164,6 +178,16 @@ with
order by date
rows between unbounded preceding and current row
) as current_ytd_waiver_payments_in_gbp,
sum(current_month_mtd_total_revenue_churn_12m) over (
partition by financial_year, dimension, dimension_value
order by date
rows between unbounded preceding and current row
) as current_ytd_total_revenue_churn_12m,
sum(current_month_mtd_total_revenue_global_12m) over (
partition by financial_year, dimension, dimension_value
order by date
rows between unbounded preceding and current row
) as current_ytd_total_revenue_global_12m,
-- Specific treatment for live_deals as it is a counter
current_month_mtd_live_deals as current_ytd_live_deals,
@ -223,6 +247,16 @@ with
order by date
rows between unbounded preceding and current row
) as previous_ytd_waiver_payments_in_gbp,
sum(previous_year_mtd_total_revenue_churn_12m) over (
partition by financial_year, dimension, dimension_value
order by date
rows between unbounded preceding and current row
) as previous_ytd_total_revenue_churn_12m,
sum(previous_year_mtd_total_revenue_global_12m) over (
partition by financial_year, dimension, dimension_value
order by date
rows between unbounded preceding and current row
) as previous_ytd_total_revenue_global_12m,
-- Specific treatment for live_deals as it is a counter
previous_year_mtd_live_deals as previous_ytd_live_deals
@ -247,6 +281,9 @@ select
coalesce(current_month_mtd_waiver_payments_in_gbp, 0) / nullif(
current_month_mtd_billable_bookings, 0
) as current_month_mtd_waiver_revenue_per_billable_booking,
coalesce(current_month_mtd_total_revenue_churn_12m, 0) / nullif(
current_month_mtd_total_revenue_global_12m, 0
) as current_month_mtd_total_revenue_churn_rate,
-- Previous Year (12 months ago), Month To Date Metrics --
abs(coalesce(previous_year_mtd_xero_waiver_paid_back_to_host_in_gbp, 0)) / nullif(
@ -263,6 +300,9 @@ select
coalesce(previous_year_mtd_waiver_payments_in_gbp, 0) / nullif(
previous_year_mtd_billable_bookings, 0
) as previous_year_mtd_waiver_revenue_per_billable_booking,
coalesce(previous_year_mtd_total_revenue_churn_12m, 0) / nullif(
previous_year_mtd_total_revenue_global_12m, 0
) as previous_year_mtd_total_revenue_churn_rate,
-- Previous Month, End Of Month Metrics --
abs(coalesce(previous_month_eom_xero_waiver_paid_back_to_host_in_gbp, 0)) / nullif(
@ -279,6 +319,9 @@ select
coalesce(previous_month_eom_waiver_payments_in_gbp, 0) / nullif(
previous_month_eom_billable_bookings, 0
) as previous_month_eom_waiver_revenue_per_billable_booking,
coalesce(previous_month_eom_total_revenue_churn_12m, 0) / nullif(
previous_month_eom_total_revenue_global_12m, 0
) as previous_month_eom_total_revenue_churn_rate,
-- Current Financial Year, Year To Date Metrics --
abs(coalesce(current_ytd_xero_waiver_paid_back_to_host_in_gbp, 0))
@ -292,6 +335,9 @@ select
coalesce(current_ytd_waiver_payments_in_gbp, 0) / nullif(
current_ytd_billable_bookings, 0
) as current_ytd_waiver_revenue_per_billable_booking,
coalesce(current_ytd_total_revenue_churn_12m, 0) / nullif(
current_ytd_total_revenue_global_12m, 0
) as current_ytd_total_revenue_churn_rate,
-- Previous Financial Year, Year To Date Metrics --
abs(coalesce(previous_ytd_xero_waiver_paid_back_to_host_in_gbp, 0))
@ -304,6 +350,9 @@ select
) as previous_ytd_operator_revenue_per_billable_booking,
coalesce(previous_ytd_waiver_payments_in_gbp, 0) / nullif(
previous_ytd_billable_bookings, 0
) as previous_ytd_waiver_revenue_per_billable_booking
) as previous_ytd_waiver_revenue_per_billable_booking,
coalesce(previous_ytd_total_revenue_churn_12m, 0) / nullif(
previous_ytd_total_revenue_global_12m, 0
) as previous_ytd_total_revenue_churn_rate
from ytd_mtd_main_metrics_overview