Merged PR 4759: Adds Booking Fee per Billable Booking

# Description

Changes:
* Creates Booking Fees in YTD/MTD
* Creates Booking Fees per Billable Booking in YTD/MTD. This is exposed forward.
* Removes code for Onboarding MRR in YTD/MTD.

Additional fixes:
* Small mistake - Revenue Churn is now considered as NEGATIVE

# 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: #28560
This commit is contained in:
Oriol Roqué Paniagua 2025-03-20 16:01:27 +00:00
parent 098ab51439
commit 6b9434355a
3 changed files with 78 additions and 22 deletions

View file

@ -40,7 +40,7 @@ with
as current_month_mtd_total_revenue_churn_12m,
total_revenue_global_preceding_12_months
as current_month_mtd_total_revenue_global_12m,
expected_mrr as current_month_mtd_onboarding_mrr,
xero_booking_net_fees_in_gbp as current_month_mtd_booking_net_fees_in_gbp,
-- Previous Year (12 months ago), Month To Date Metrics --
previous_year_total_revenue_in_gbp
@ -67,7 +67,8 @@ with
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_year_expected_mrr as previous_year_mtd_onboarding_mrr,
previous_year_xero_booking_net_fees_in_gbp
as previous_year_mtd_booking_net_fees_in_gbp,
-- Previous Month, End Of Month Metrics --
lag(total_revenue_in_gbp) over (
@ -112,9 +113,9 @@ with
lag(total_revenue_global_preceding_12_months) over (
partition by dimension, dimension_value order by date
) as previous_month_eom_total_revenue_global_12m,
lag(expected_mrr) over (
lag(xero_booking_net_fees_in_gbp) over (
partition by dimension, dimension_value order by date
) as previous_month_eom_onboarding_mrr
) as previous_month_eom_booking_net_fees_in_gbp
from int_mtd_vs_previous_year_metrics
where
@ -193,11 +194,11 @@ with
order by date
rows between unbounded preceding and current row
) as current_ytd_total_revenue_global_12m,
sum(current_month_mtd_onboarding_mrr) over (
sum(current_month_mtd_booking_net_fees_in_gbp) over (
partition by financial_year, dimension, dimension_value
order by date
rows between unbounded preceding and current row
) as current_ytd_onboarding_mrr,
) as current_ytd_booking_net_fees_in_gbp,
-- Specific treatment for live_deals as it is a counter
current_month_mtd_live_deals as current_ytd_live_deals,
@ -267,11 +268,11 @@ with
order by date
rows between unbounded preceding and current row
) as previous_ytd_total_revenue_global_12m,
sum(previous_year_mtd_onboarding_mrr) over (
sum(previous_year_mtd_booking_net_fees_in_gbp) over (
partition by financial_year, dimension, dimension_value
order by date
rows between unbounded preceding and current row
) as previous_ytd_onboarding_mrr,
) as previous_ytd_booking_net_fees_in_gbp,
-- Specific treatment for live_deals as it is a counter
previous_year_mtd_live_deals as previous_ytd_live_deals
@ -299,6 +300,9 @@ select
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,
coalesce(current_month_mtd_booking_net_fees_in_gbp, 0) / nullif(
current_month_mtd_billable_bookings, 0
) as current_month_mtd_booking_net_fees_per_billable_booking,
-- Previous Year (12 months ago), Month To Date Metrics --
abs(coalesce(previous_year_mtd_xero_waiver_paid_back_to_host_in_gbp, 0)) / nullif(
@ -318,6 +322,9 @@ select
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,
coalesce(previous_year_mtd_booking_net_fees_in_gbp, 0) / nullif(
previous_year_mtd_billable_bookings, 0
) as previous_year_mtd_booking_net_fees_per_billable_booking,
-- Previous Month, End Of Month Metrics --
abs(coalesce(previous_month_eom_xero_waiver_paid_back_to_host_in_gbp, 0)) / nullif(
@ -337,6 +344,9 @@ select
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,
coalesce(previous_month_eom_booking_net_fees_in_gbp, 0) / nullif(
previous_month_eom_billable_bookings, 0
) as previous_month_eom_booking_net_fees_per_billable_booking,
-- Current Financial Year, Year To Date Metrics --
abs(coalesce(current_ytd_xero_waiver_paid_back_to_host_in_gbp, 0))
@ -353,6 +363,9 @@ select
coalesce(current_ytd_total_revenue_churn_12m, 0) / nullif(
current_ytd_total_revenue_global_12m, 0
) as current_ytd_total_revenue_churn_rate,
coalesce(current_ytd_booking_net_fees_in_gbp, 0) / nullif(
current_ytd_billable_bookings, 0
) as current_ytd_booking_net_fees_per_billable_booking,
-- Previous Financial Year, Year To Date Metrics --
abs(coalesce(previous_ytd_xero_waiver_paid_back_to_host_in_gbp, 0))
@ -368,6 +381,9 @@ select
) 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
) as previous_ytd_total_revenue_churn_rate,
coalesce(previous_ytd_booking_net_fees_in_gbp, 0) / nullif(
previous_ytd_billable_bookings, 0
) as previous_ytd_booking_net_fees_per_billable_booking
from ytd_mtd_main_metrics_overview