wip fixing deals from hubspot
This commit is contained in:
parent
cf024f7b71
commit
26898322e7
6 changed files with 136 additions and 213 deletions
|
|
@ -171,8 +171,11 @@ with
|
|||
dimension in ('global', 'by_number_of_listings', 'by_billing_country')
|
||||
and dimension_value <> 'UNSET'
|
||||
),
|
||||
int_mtd_agg_onboarding_mrr_metrics as (
|
||||
select * from {{ ref("int_mtd_agg_onboarding_mrr_metrics") }}
|
||||
int_monthly_onboarding_mrr_per_deal as (
|
||||
select * from {{ ref("int_monthly_onboarding_mrr_per_deal") }}
|
||||
),
|
||||
int_mtd_agg_onboarding_mrr_revenue as (
|
||||
select * from {{ ref("int_mtd_agg_onboarding_mrr_revenue") }}
|
||||
),
|
||||
|
||||
plain_kpi_combination as (
|
||||
|
|
@ -266,10 +269,9 @@ with
|
|||
as host_resolution_amount_paid_per_created_booking,
|
||||
{{
|
||||
return_capped_value(
|
||||
"cast(host_resolutions.xero_host_resolution_payment_count as decimal)
|
||||
/ created_bookings.created_bookings",
|
||||
"cast(host_resolutions.xero_host_resolution_payment_count as decimal) / created_bookings.created_bookings",
|
||||
-1,
|
||||
1
|
||||
1,
|
||||
)
|
||||
}}
|
||||
as host_resolution_payment_per_created_booking_ratio,
|
||||
|
|
@ -347,21 +349,12 @@ with
|
|||
) as revenue_retained_in_gbp,
|
||||
{{
|
||||
return_capped_value(
|
||||
"nullif(
|
||||
coalesce(guest_payments.total_guest_payments_in_gbp, 0)
|
||||
+ coalesce(invoiced_revenue.xero_operator_net_fees_in_gbp, 0)
|
||||
+ coalesce(invoiced_revenue.xero_apis_net_fees_in_gbp, 0)
|
||||
+ coalesce(invoiced_revenue.xero_waiver_paid_back_to_host_in_gbp, 0),
|
||||
0
|
||||
) / nullif(
|
||||
coalesce(guest_payments.total_guest_payments_in_gbp, 0)
|
||||
+ coalesce(invoiced_revenue.xero_operator_net_fees_in_gbp, 0)
|
||||
+ coalesce(invoiced_revenue.xero_apis_net_fees_in_gbp, 0),
|
||||
0
|
||||
)",
|
||||
"nullif( coalesce(guest_payments.total_guest_payments_in_gbp, 0) + coalesce(invoiced_revenue.xero_operator_net_fees_in_gbp, 0) + coalesce(invoiced_revenue.xero_apis_net_fees_in_gbp, 0) + coalesce(invoiced_revenue.xero_waiver_paid_back_to_host_in_gbp, 0), 0 ) / nullif( coalesce(guest_payments.total_guest_payments_in_gbp, 0) + coalesce(invoiced_revenue.xero_operator_net_fees_in_gbp, 0) + coalesce(invoiced_revenue.xero_apis_net_fees_in_gbp, 0), 0 )",
|
||||
-1,
|
||||
1
|
||||
)}} as revenue_retained_ratio,
|
||||
1,
|
||||
)
|
||||
}}
|
||||
as revenue_retained_ratio,
|
||||
|
||||
-- INCOME RETAINED POST RESOLUTIONS--
|
||||
nullif(
|
||||
|
|
@ -374,27 +367,16 @@ with
|
|||
) as revenue_retained_post_resolutions_in_gbp,
|
||||
{{
|
||||
return_capped_value(
|
||||
"nullif(
|
||||
coalesce(guest_payments.total_guest_payments_in_gbp, 0)
|
||||
+ coalesce(invoiced_revenue.xero_operator_net_fees_in_gbp, 0)
|
||||
+ coalesce(invoiced_revenue.xero_apis_net_fees_in_gbp, 0)
|
||||
+ coalesce(invoiced_revenue.xero_waiver_paid_back_to_host_in_gbp, 0)
|
||||
+ coalesce(host_resolutions.xero_host_resolution_amount_paid_in_gbp, 0),
|
||||
0
|
||||
) / nullif(
|
||||
coalesce(guest_payments.total_guest_payments_in_gbp, 0)
|
||||
+ coalesce(invoiced_revenue.xero_operator_net_fees_in_gbp, 0)
|
||||
+ coalesce(invoiced_revenue.xero_apis_net_fees_in_gbp, 0),
|
||||
0
|
||||
)",
|
||||
"nullif( coalesce(guest_payments.total_guest_payments_in_gbp, 0) + coalesce(invoiced_revenue.xero_operator_net_fees_in_gbp, 0) + coalesce(invoiced_revenue.xero_apis_net_fees_in_gbp, 0) + coalesce(invoiced_revenue.xero_waiver_paid_back_to_host_in_gbp, 0) + coalesce(host_resolutions.xero_host_resolution_amount_paid_in_gbp, 0), 0 ) / nullif( coalesce(guest_payments.total_guest_payments_in_gbp, 0) + coalesce(invoiced_revenue.xero_operator_net_fees_in_gbp, 0) + coalesce(invoiced_revenue.xero_apis_net_fees_in_gbp, 0), 0 )",
|
||||
-1,
|
||||
1
|
||||
1,
|
||||
)
|
||||
}} as revenue_retained_post_resolutions_ratio,
|
||||
}}
|
||||
as revenue_retained_post_resolutions_ratio,
|
||||
|
||||
-- ONBOARDING MRR METRIC --
|
||||
onboarding_mrr.expected_mrr_per_deal,
|
||||
onboarding_mrr.expected_mrr
|
||||
onboarding_mrr_revenue.expected_mrr
|
||||
|
||||
from int_kpis__agg_dates_main_kpis d
|
||||
left join
|
||||
|
|
@ -468,10 +450,15 @@ with
|
|||
and d.dimension = churn.dimension
|
||||
and d.dimension_value = churn.dimension_value
|
||||
left join
|
||||
int_mtd_agg_onboarding_mrr_metrics onboarding_mrr
|
||||
int_monthly_onboarding_mrr_per_deal onboarding_mrr
|
||||
on d.date = onboarding_mrr.date
|
||||
and d.dimension = onboarding_mrr.dimension
|
||||
and d.dimension_value = onboarding_mrr.dimension_value
|
||||
left join
|
||||
int_mtd_agg_onboarding_mrr_revenue onboarding_mrr_revenue
|
||||
on d.date = onboarding_mrr_revenue.date
|
||||
and d.dimension = onboarding_mrr_revenue.dimension
|
||||
and d.dimension_value = onboarding_mrr_revenue.dimension_value
|
||||
)
|
||||
|
||||
select
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue