This commit is contained in:
Joaquin Ossa 2025-01-28 16:47:44 +01:00
parent cea7cdb34d
commit cf024f7b71
3 changed files with 20 additions and 19 deletions

View file

@ -1,25 +1,22 @@
with
monthly_new_deals as (
select
date_trunc('MONTH', effective_deal_start_date_utc)::date as start_month,
hubspot_listing_segmentation,
count(id_deal) as number_of_new_deals
from {{ ref("int_kpis__dimension_deals") }}
group by 1, 2
int_kpis__agg_daily_deals as (
select date, dimension_value as hubspot_listing_segmentation, new_deals
from {{ ref("int_kpis__agg_daily_deals") }}
where dimension = 'by_number_of_listings'
),
onboarding_mrr_metrics as (
select
mom.date,
'by_number_of_listings' as dimension,
mom.hubspot_listing_segmentation as dimension_value,
mnd.number_of_new_deals,
ad.number_of_new_deals,
mom.expected_mrr as expected_mrr_per_deal,
mom.expected_mrr * mnd.number_of_new_deals as expected_mrr
mom.expected_mrr * ad.number_of_new_deals as expected_mrr
from {{ ref("int_monthly_onboarding_mrr_metrics") }} mom
left join
monthly_new_deals mnd
on date_trunc('MONTH', mom.date)::date = mnd.start_month
and mom.hubspot_listing_segmentation = mnd.hubspot_listing_segmentation
int_kpis__agg_daily_deals ad
on mom.date = ad.date
and mom.hubspot_listing_segmentation = ad.hubspot_listing_segmentation
where
mom.main_billing_country_iso_3 = 'global'
and mom.hubspot_listing_segmentation <> 'global'