Merged PR 4231: Changed MRR logic

# Description

Changed the MRR way of being considered, now it uses for the ongoing month the revenue of the 12 months previous to that one.
Not both MRR metrics will only not show in the current month.
Changed the rule for metrics depending on invoicing so that they show the previous month value from the 20th onward of the current month

# 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: #26820
This commit is contained in:
Joaquin Ossa 2025-01-31 08:32:21 +00:00
commit 1f95d0ee6b
3 changed files with 20 additions and 9 deletions

View file

@ -1,6 +1,10 @@
with
int_monthly_aggregated_metrics_history_by_deal as (
select * from {{ ref("int_monthly_aggregated_metrics_history_by_deal") }}
select
(date_trunc('month', date) + interval '2 month' - interval '1 day')::date
as next_month_end_date,
*
from {{ ref("int_monthly_aggregated_metrics_history_by_deal") }}
),
int_kpis__dimension_deals as (select * from {{ ref("int_kpis__dimension_deals") }}),
deal_attributes as (
@ -20,7 +24,7 @@ with
)
-- Calculate expected MRR per deal by each dimension
select
m.date,
m.next_month_end_date as date,
'by_number_of_listings' as dimension,
d.hubspot_listing_segmentation as dimension_value,
sum(coalesce(m.total_revenue_in_gbp, 0)) / count(*) as expected_mrr_per_deal
@ -36,7 +40,7 @@ where d.hubspot_listing_segmentation <> 'UNSET'
group by 1, 2, 3
union all
select
m.date,
m.next_month_end_date as date,
'by_billing_country' as dimension,
d.main_billing_country_iso_3_per_deal as dimension_value,
sum(coalesce(m.total_revenue_in_gbp, 0)) / count(*) as expected_mrr_per_deal
@ -52,7 +56,7 @@ where d.hubspot_listing_segmentation <> 'UNSET'
group by 1, 2, 3
union all
select
m.date,
m.next_month_end_date as date,
'global' as dimension,
'global' as dimension_value,
sum(coalesce(m.total_revenue_in_gbp, 0)) / count(*) as expected_mrr_per_deal

View file

@ -1712,8 +1712,11 @@ models:
"This table provides data on the Onboarding Monthly Recurring Revenue (MRR).
The Onboarding MRR is an estimate of the expected monthly revenue generated by
each new deal. It is calculated by taking the total revenue generated by all
active accounts over the last 12 months and dividing it by the number of active
months for each account."
active accounts over the last 12 previous months (before the ongoing month)
and dividing it by the number of active months for each account during this
period.
For example in December 2023 we will calculate the Onboarding MRR for a deal
using the revenue from December 2022 to November 2023."
data_tests:
- dbt_utils.unique_combination_of_columns:

View file

@ -68,7 +68,6 @@ where
or lower(metric) like '%resolutions%'
or lower(metric) like '%invoiced%'
or lower(metric) like '%retained%'
or lower(metric) like '%mrr%'
or lower(metric) like '%damage host%'
)
and {{ is_date_before_previous_month("date") }}
@ -84,5 +83,10 @@ where
or lower(metric) like '%damage host%'
)
)
-- If metric is Churn Rate, do not show month in progress
and not (lower(metric) like '%churn rate%' and is_current_month = true)
-- If metric is Churn Rate or Expected MRR, do not show month in progress.
-- Unlike other revenue metrics, Expected MRR is calculated for the next month,
-- so it is not affected by the invoicing cycle.
and not (
(lower(metric) like '%churn rate%' or lower(metric) like '%mrr%')
and is_current_month = true
)