Merged PR 3413: Exposes New KPIs of Bookings, Guest Journeys and Guest Payments
# Description Exposes New KPIs of Bookings, Guest Journeys and Guest Payments in the 2 main flows: Monthly+MTD per Global, By Billing Country and By # of Listings Segmentation & Monthly By Deal I did some checks on Global and By Billing Country and looks good. I checked some examples for Monthly By Deal and looks good. # 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. - [NO] I have checked for DRY opportunities with other models and docs. **Likely there's ways to create default configs for KPIs saying "hey, this is Main KPIs for a specific view so use this models and these filters". But at this stage since it's a transitional stage I don't want do overthink. Let's tackle this later on if that's ok for you. It means we will live with some repeated expressions** - [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: #23455
This commit is contained in:
parent
aeaf78df16
commit
9b0c7161e3
2 changed files with 259 additions and 71 deletions
|
|
@ -5,20 +5,56 @@ This model aggregates the different metrics by deal for those hosts that have it
|
||||||
with
|
with
|
||||||
int_dates_by_deal as (select * from {{ ref("int_dates_by_deal") }}),
|
int_dates_by_deal as (select * from {{ ref("int_dates_by_deal") }}),
|
||||||
int_mtd_deal_lifecycle as (select * from {{ ref("int_mtd_deal_lifecycle") }}),
|
int_mtd_deal_lifecycle as (select * from {{ ref("int_mtd_deal_lifecycle") }}),
|
||||||
int_core__monthly_guest_journey_history_by_deal as (
|
|
||||||
select * from {{ ref("int_core__monthly_guest_journey_history_by_deal") }}
|
|
||||||
),
|
|
||||||
int_core__monthly_accommodation_history_by_deal as (
|
int_core__monthly_accommodation_history_by_deal as (
|
||||||
select * from {{ ref("int_core__monthly_accommodation_history_by_deal") }}
|
select * from {{ ref("int_core__monthly_accommodation_history_by_deal") }}
|
||||||
),
|
),
|
||||||
int_core__monthly_booking_history_by_deal as (
|
created_bookings as (
|
||||||
select * from {{ ref("int_core__monthly_booking_history_by_deal") }}
|
select *
|
||||||
|
from {{ ref("int_kpis__aggregated_monthly_created_bookings") }}
|
||||||
|
where dimension in ('by_deal') and dimension_value <> 'UNSET'
|
||||||
|
),
|
||||||
|
check_out_bookings as (
|
||||||
|
select *
|
||||||
|
from {{ ref("int_kpis__aggregated_monthly_check_out_bookings") }}
|
||||||
|
where dimension in ('by_deal') and dimension_value <> 'UNSET'
|
||||||
|
),
|
||||||
|
cancelled_bookings as (
|
||||||
|
select *
|
||||||
|
from {{ ref("int_kpis__aggregated_monthly_cancelled_bookings") }}
|
||||||
|
where dimension in ('by_deal') and dimension_value <> 'UNSET'
|
||||||
|
),
|
||||||
|
billable_bookings as (
|
||||||
|
select *
|
||||||
|
from {{ ref("int_kpis__aggregated_monthly_billable_bookings") }}
|
||||||
|
where dimension in ('by_deal') and dimension_value <> 'UNSET'
|
||||||
|
),
|
||||||
|
created_guest_journeys as (
|
||||||
|
select *
|
||||||
|
from {{ ref("int_kpis__aggregated_monthly_created_guest_journeys") }}
|
||||||
|
where dimension in ('by_deal') and dimension_value <> 'UNSET'
|
||||||
|
),
|
||||||
|
started_guest_journeys as (
|
||||||
|
select *
|
||||||
|
from {{ ref("int_kpis__aggregated_monthly_started_guest_journeys") }}
|
||||||
|
where dimension in ('by_deal') and dimension_value <> 'UNSET'
|
||||||
|
),
|
||||||
|
completed_guest_journeys as (
|
||||||
|
select *
|
||||||
|
from {{ ref("int_kpis__aggregated_monthly_completed_guest_journeys") }}
|
||||||
|
where dimension in ('by_deal') and dimension_value <> 'UNSET'
|
||||||
|
),
|
||||||
|
guest_journeys_with_payment as (
|
||||||
|
select *
|
||||||
|
from {{ ref("int_kpis__aggregated_monthly_guest_journeys_with_payment") }}
|
||||||
|
where dimension in ('by_deal') and dimension_value <> 'UNSET'
|
||||||
|
),
|
||||||
|
guest_payments as (
|
||||||
|
select *
|
||||||
|
from {{ ref("int_kpis__aggregated_monthly_guest_payments") }}
|
||||||
|
where dimension in ('by_deal') and dimension_value <> 'UNSET'
|
||||||
),
|
),
|
||||||
int_xero__monthly_invoicing_history_by_deal as (
|
int_xero__monthly_invoicing_history_by_deal as (
|
||||||
select * from {{ ref("int_xero__monthly_invoicing_history_by_deal") }}
|
select * from {{ ref("int_xero__monthly_invoicing_history_by_deal") }}
|
||||||
),
|
|
||||||
int_core__monthly_guest_payments_history_by_deal as (
|
|
||||||
select * from {{ ref("int_core__monthly_guest_payments_history_by_deal") }}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
select
|
select
|
||||||
|
|
@ -34,20 +70,25 @@ select
|
||||||
deal_lifecycle.deal_lifecycle_state,
|
deal_lifecycle.deal_lifecycle_state,
|
||||||
|
|
||||||
-- BOOKINGS --
|
-- BOOKINGS --
|
||||||
bookings.created_bookings,
|
created_bookings.created_bookings,
|
||||||
bookings.check_out_bookings,
|
check_out_bookings.check_out_bookings,
|
||||||
bookings.cancelled_bookings,
|
cancelled_bookings.cancelled_bookings,
|
||||||
bookings.billable_bookings,
|
billable_bookings.billable_bookings,
|
||||||
|
|
||||||
-- GUEST JOURNEYS --
|
-- GUEST JOURNEYS --
|
||||||
guest_journeys.created_guest_journeys,
|
created_guest_journeys.created_guest_journeys,
|
||||||
guest_journeys.started_guest_journeys,
|
started_guest_journeys.started_guest_journeys,
|
||||||
guest_journeys.completed_guest_journeys,
|
completed_guest_journeys.completed_guest_journeys,
|
||||||
guest_journeys.paid_guest_journeys,
|
guest_journeys_with_payment.guest_journeys_with_payment as paid_guest_journeys,
|
||||||
guest_journeys.start_rate_guest_journey,
|
cast(started_guest_journeys.started_guest_journeys as decimal)
|
||||||
guest_journeys.completion_rate_guest_journey,
|
/ created_guest_journeys.created_guest_journeys as start_rate_guest_journey,
|
||||||
guest_journeys.incompletion_rate_guest_journey,
|
cast(completed_guest_journeys.completed_guest_journeys as decimal)
|
||||||
guest_journeys.payment_rate_guest_journey,
|
/ started_guest_journeys.started_guest_journeys as completion_rate_guest_journey,
|
||||||
|
1
|
||||||
|
- cast(completed_guest_journeys.completed_guest_journeys as decimal)
|
||||||
|
/ started_guest_journeys.started_guest_journeys as incompletion_rate_guest_journey,
|
||||||
|
cast(guest_journeys_with_payment.guest_journeys_with_payment as decimal)
|
||||||
|
/ completed_guest_journeys.completed_guest_journeys as payment_rate_guest_journey,
|
||||||
|
|
||||||
-- LISTINGS --
|
-- LISTINGS --
|
||||||
accommodations.new_listings,
|
accommodations.new_listings,
|
||||||
|
|
@ -98,10 +139,10 @@ select
|
||||||
|
|
||||||
-- GUEST REVENUE AND PAYMENTS WEIGHTED METRICS --
|
-- GUEST REVENUE AND PAYMENTS WEIGHTED METRICS --
|
||||||
guest_payments.total_guest_payments_in_gbp / nullif(
|
guest_payments.total_guest_payments_in_gbp / nullif(
|
||||||
guest_journeys.completed_guest_journeys, 0
|
completed_guest_journeys.completed_guest_journeys, 0
|
||||||
) as guest_payments_per_completed_guest_journey,
|
) as guest_payments_per_completed_guest_journey,
|
||||||
guest_payments.total_guest_payments_in_gbp / nullif(
|
guest_payments.total_guest_payments_in_gbp / nullif(
|
||||||
guest_journeys.paid_guest_journeys, 0
|
guest_journeys_with_payment.guest_journeys_with_payment, 0
|
||||||
) as guest_payments_per_paid_guest_journey,
|
) as guest_payments_per_paid_guest_journey,
|
||||||
|
|
||||||
-- TOTAL REVENUE WEIGHTED METRICS --
|
-- TOTAL REVENUE WEIGHTED METRICS --
|
||||||
|
|
@ -110,13 +151,13 @@ select
|
||||||
+ coalesce(invoicing.xero_operator_net_fees_in_gbp, 0)
|
+ coalesce(invoicing.xero_operator_net_fees_in_gbp, 0)
|
||||||
+ coalesce(invoicing.xero_apis_net_fees_in_gbp, 0)
|
+ coalesce(invoicing.xero_apis_net_fees_in_gbp, 0)
|
||||||
)
|
)
|
||||||
/ nullif(bookings.created_bookings, 0) as total_revenue_per_created_booking,
|
/ nullif(created_bookings.created_bookings, 0) as total_revenue_per_created_booking,
|
||||||
(
|
(
|
||||||
coalesce(guest_payments.total_guest_payments_in_gbp, 0)
|
coalesce(guest_payments.total_guest_payments_in_gbp, 0)
|
||||||
+ coalesce(invoicing.xero_operator_net_fees_in_gbp, 0)
|
+ coalesce(invoicing.xero_operator_net_fees_in_gbp, 0)
|
||||||
+ coalesce(invoicing.xero_apis_net_fees_in_gbp, 0)
|
+ coalesce(invoicing.xero_apis_net_fees_in_gbp, 0)
|
||||||
) / nullif(
|
) / nullif(
|
||||||
guest_journeys.created_guest_journeys, 0
|
created_guest_journeys.created_guest_journeys, 0
|
||||||
) as total_revenue_per_created_guest_journey,
|
) as total_revenue_per_created_guest_journey,
|
||||||
(
|
(
|
||||||
coalesce(guest_payments.total_guest_payments_in_gbp, 0)
|
coalesce(guest_payments.total_guest_payments_in_gbp, 0)
|
||||||
|
|
@ -132,21 +173,45 @@ left join
|
||||||
on d.date = deal_lifecycle.date
|
on d.date = deal_lifecycle.date
|
||||||
and d.id_deal = deal_lifecycle.id_deal
|
and d.id_deal = deal_lifecycle.id_deal
|
||||||
left join
|
left join
|
||||||
int_core__monthly_booking_history_by_deal bookings
|
created_bookings
|
||||||
on d.date = bookings.date
|
on d.date = created_bookings.end_date
|
||||||
and d.id_deal = bookings.id_deal
|
and d.id_deal = created_bookings.dimension_value
|
||||||
left join
|
left join
|
||||||
int_core__monthly_guest_journey_history_by_deal guest_journeys
|
check_out_bookings
|
||||||
on d.date = guest_journeys.date
|
on d.date = check_out_bookings.end_date
|
||||||
and d.id_deal = guest_journeys.id_deal
|
and d.id_deal = check_out_bookings.dimension_value
|
||||||
|
left join
|
||||||
|
cancelled_bookings
|
||||||
|
on d.date = cancelled_bookings.end_date
|
||||||
|
and d.id_deal = cancelled_bookings.dimension_value
|
||||||
|
left join
|
||||||
|
billable_bookings
|
||||||
|
on d.date = billable_bookings.end_date
|
||||||
|
and d.id_deal = billable_bookings.dimension_value
|
||||||
|
left join
|
||||||
|
created_guest_journeys
|
||||||
|
on d.date = created_guest_journeys.end_date
|
||||||
|
and d.id_deal = created_guest_journeys.dimension_value
|
||||||
|
left join
|
||||||
|
started_guest_journeys
|
||||||
|
on d.date = started_guest_journeys.end_date
|
||||||
|
and d.id_deal = started_guest_journeys.dimension_value
|
||||||
|
left join
|
||||||
|
completed_guest_journeys
|
||||||
|
on d.date = completed_guest_journeys.end_date
|
||||||
|
and d.id_deal = completed_guest_journeys.dimension_value
|
||||||
|
left join
|
||||||
|
guest_journeys_with_payment
|
||||||
|
on d.date = guest_journeys_with_payment.end_date
|
||||||
|
and d.id_deal = guest_journeys_with_payment.dimension_value
|
||||||
|
left join
|
||||||
|
guest_payments
|
||||||
|
on d.date = guest_payments.end_date
|
||||||
|
and d.id_deal = guest_payments.dimension_value
|
||||||
left join
|
left join
|
||||||
int_core__monthly_accommodation_history_by_deal accommodations
|
int_core__monthly_accommodation_history_by_deal accommodations
|
||||||
on d.date = accommodations.date
|
on d.date = accommodations.date
|
||||||
and d.id_deal = accommodations.id_deal
|
and d.id_deal = accommodations.id_deal
|
||||||
left join
|
|
||||||
int_core__monthly_guest_payments_history_by_deal guest_payments
|
|
||||||
on d.date = guest_payments.date
|
|
||||||
and d.id_deal = guest_payments.id_deal
|
|
||||||
left join
|
left join
|
||||||
int_xero__monthly_invoicing_history_by_deal invoicing
|
int_xero__monthly_invoicing_history_by_deal invoicing
|
||||||
on d.date = invoicing.date
|
on d.date = invoicing.date
|
||||||
|
|
|
||||||
|
|
@ -4,27 +4,126 @@ previous year for each line & computing relative increment. --
|
||||||
*/
|
*/
|
||||||
{{ config(materialized="table", unique_key=["date", "dimension", "dimension_value"]) }}
|
{{ config(materialized="table", unique_key=["date", "dimension", "dimension_value"]) }}
|
||||||
with
|
with
|
||||||
int_core__mtd_created_bookings_metric as (
|
created_bookings as (
|
||||||
select * from {{ ref("int_core__mtd_created_bookings_metric") }}
|
select *
|
||||||
|
from {{ ref("int_kpis__aggregated_mtd_created_bookings") }}
|
||||||
|
where
|
||||||
|
dimension in ('global', 'by_number_of_listings', 'by_billing_country')
|
||||||
|
and dimension_value <> 'UNSET'
|
||||||
|
union all
|
||||||
|
select *
|
||||||
|
from {{ ref("int_kpis__aggregated_monthly_created_bookings") }}
|
||||||
|
where
|
||||||
|
dimension in ('global', 'by_number_of_listings', 'by_billing_country')
|
||||||
|
and dimension_value <> 'UNSET'
|
||||||
),
|
),
|
||||||
int_core__mtd_check_out_bookings_metric as (
|
check_out_bookings as (
|
||||||
select * from {{ ref("int_core__mtd_check_out_bookings_metric") }}
|
select *
|
||||||
|
from {{ ref("int_kpis__aggregated_mtd_check_out_bookings") }}
|
||||||
|
where
|
||||||
|
dimension in ('global', 'by_number_of_listings', 'by_billing_country')
|
||||||
|
and dimension_value <> 'UNSET'
|
||||||
|
union all
|
||||||
|
select *
|
||||||
|
from {{ ref("int_kpis__aggregated_monthly_check_out_bookings") }}
|
||||||
|
where
|
||||||
|
dimension in ('global', 'by_number_of_listings', 'by_billing_country')
|
||||||
|
and dimension_value <> 'UNSET'
|
||||||
),
|
),
|
||||||
int_core__mtd_cancelled_bookings_metric as (
|
cancelled_bookings as (
|
||||||
select * from {{ ref("int_core__mtd_cancelled_bookings_metric") }}
|
select *
|
||||||
|
from {{ ref("int_kpis__aggregated_mtd_cancelled_bookings") }}
|
||||||
|
where
|
||||||
|
dimension in ('global', 'by_number_of_listings', 'by_billing_country')
|
||||||
|
and dimension_value <> 'UNSET'
|
||||||
|
union all
|
||||||
|
select *
|
||||||
|
from {{ ref("int_kpis__aggregated_monthly_cancelled_bookings") }}
|
||||||
|
where
|
||||||
|
dimension in ('global', 'by_number_of_listings', 'by_billing_country')
|
||||||
|
and dimension_value <> 'UNSET'
|
||||||
),
|
),
|
||||||
int_core__mtd_billable_bookings_metric as (
|
billable_bookings as (
|
||||||
select * from {{ ref("int_core__mtd_billable_bookings_metric") }}
|
select *
|
||||||
|
from {{ ref("int_kpis__aggregated_mtd_billable_bookings") }}
|
||||||
|
where
|
||||||
|
dimension in ('global', 'by_number_of_listings', 'by_billing_country')
|
||||||
|
and dimension_value <> 'UNSET'
|
||||||
|
union all
|
||||||
|
select *
|
||||||
|
from {{ ref("int_kpis__aggregated_monthly_billable_bookings") }}
|
||||||
|
where
|
||||||
|
dimension in ('global', 'by_number_of_listings', 'by_billing_country')
|
||||||
|
and dimension_value <> 'UNSET'
|
||||||
),
|
),
|
||||||
int_core__mtd_guest_journey_metrics as (
|
created_guest_journeys as (
|
||||||
select * from {{ ref("int_core__mtd_guest_journey_metrics") }}
|
select *
|
||||||
|
from {{ ref("int_kpis__aggregated_mtd_created_guest_journeys") }}
|
||||||
|
where
|
||||||
|
dimension in ('global', 'by_number_of_listings', 'by_billing_country')
|
||||||
|
and dimension_value <> 'UNSET'
|
||||||
|
union all
|
||||||
|
select *
|
||||||
|
from {{ ref("int_kpis__aggregated_monthly_created_guest_journeys") }}
|
||||||
|
where
|
||||||
|
dimension in ('global', 'by_number_of_listings', 'by_billing_country')
|
||||||
|
and dimension_value <> 'UNSET'
|
||||||
|
),
|
||||||
|
started_guest_journeys as (
|
||||||
|
select *
|
||||||
|
from {{ ref("int_kpis__aggregated_mtd_started_guest_journeys") }}
|
||||||
|
where
|
||||||
|
dimension in ('global', 'by_number_of_listings', 'by_billing_country')
|
||||||
|
and dimension_value <> 'UNSET'
|
||||||
|
union all
|
||||||
|
select *
|
||||||
|
from {{ ref("int_kpis__aggregated_monthly_started_guest_journeys") }}
|
||||||
|
where
|
||||||
|
dimension in ('global', 'by_number_of_listings', 'by_billing_country')
|
||||||
|
and dimension_value <> 'UNSET'
|
||||||
|
),
|
||||||
|
completed_guest_journeys as (
|
||||||
|
select *
|
||||||
|
from {{ ref("int_kpis__aggregated_mtd_completed_guest_journeys") }}
|
||||||
|
where
|
||||||
|
dimension in ('global', 'by_number_of_listings', 'by_billing_country')
|
||||||
|
and dimension_value <> 'UNSET'
|
||||||
|
union all
|
||||||
|
select *
|
||||||
|
from {{ ref("int_kpis__aggregated_monthly_completed_guest_journeys") }}
|
||||||
|
where
|
||||||
|
dimension in ('global', 'by_number_of_listings', 'by_billing_country')
|
||||||
|
and dimension_value <> 'UNSET'
|
||||||
|
),
|
||||||
|
guest_journeys_with_payment as (
|
||||||
|
select *
|
||||||
|
from {{ ref("int_kpis__aggregated_mtd_guest_journeys_with_payment") }}
|
||||||
|
where
|
||||||
|
dimension in ('global', 'by_number_of_listings', 'by_billing_country')
|
||||||
|
and dimension_value <> 'UNSET'
|
||||||
|
union all
|
||||||
|
select *
|
||||||
|
from {{ ref("int_kpis__aggregated_monthly_guest_journeys_with_payment") }}
|
||||||
|
where
|
||||||
|
dimension in ('global', 'by_number_of_listings', 'by_billing_country')
|
||||||
|
and dimension_value <> 'UNSET'
|
||||||
),
|
),
|
||||||
int_core__mtd_accommodation_metrics as (
|
int_core__mtd_accommodation_metrics as (
|
||||||
select * from {{ ref("int_core__mtd_accommodation_metrics") }}
|
select * from {{ ref("int_core__mtd_accommodation_metrics") }}
|
||||||
),
|
),
|
||||||
int_mtd_deal_metrics as (select * from {{ ref("int_mtd_deal_metrics") }}),
|
int_mtd_deal_metrics as (select * from {{ ref("int_mtd_deal_metrics") }}),
|
||||||
int_core__mtd_guest_payments_metrics as (
|
guest_payments as (
|
||||||
select * from {{ ref("int_core__mtd_guest_payments_metrics") }}
|
select *
|
||||||
|
from {{ ref("int_kpis__aggregated_mtd_guest_payments") }}
|
||||||
|
where
|
||||||
|
dimension in ('global', 'by_number_of_listings', 'by_billing_country')
|
||||||
|
and dimension_value <> 'UNSET'
|
||||||
|
union all
|
||||||
|
select *
|
||||||
|
from {{ ref("int_kpis__aggregated_monthly_guest_payments") }}
|
||||||
|
where
|
||||||
|
dimension in ('global', 'by_number_of_listings', 'by_billing_country')
|
||||||
|
and dimension_value <> 'UNSET'
|
||||||
),
|
),
|
||||||
int_xero__mtd_invoicing_metrics as (
|
int_xero__mtd_invoicing_metrics as (
|
||||||
select * from {{ ref("int_xero__mtd_invoicing_metrics") }}
|
select * from {{ ref("int_xero__mtd_invoicing_metrics") }}
|
||||||
|
|
@ -54,14 +153,23 @@ with
|
||||||
billable_bookings.billable_bookings,
|
billable_bookings.billable_bookings,
|
||||||
|
|
||||||
-- GUEST JOURNEYS --
|
-- GUEST JOURNEYS --
|
||||||
guest_journeys.created_guest_journeys,
|
created_guest_journeys.created_guest_journeys,
|
||||||
guest_journeys.started_guest_journeys,
|
started_guest_journeys.started_guest_journeys,
|
||||||
guest_journeys.completed_guest_journeys,
|
completed_guest_journeys.completed_guest_journeys,
|
||||||
guest_journeys.paid_guest_journeys,
|
guest_journeys_with_payment.guest_journeys_with_payment
|
||||||
guest_journeys.start_rate_guest_journey,
|
as paid_guest_journeys,
|
||||||
guest_journeys.completion_rate_guest_journey,
|
cast(started_guest_journeys.started_guest_journeys as decimal)
|
||||||
guest_journeys.incompletion_rate_guest_journey,
|
/ created_guest_journeys.created_guest_journeys as start_rate_guest_journey,
|
||||||
guest_journeys.payment_rate_guest_journey,
|
cast(completed_guest_journeys.completed_guest_journeys as decimal)
|
||||||
|
/ started_guest_journeys.started_guest_journeys
|
||||||
|
as completion_rate_guest_journey,
|
||||||
|
1
|
||||||
|
- cast(completed_guest_journeys.completed_guest_journeys as decimal)
|
||||||
|
/ started_guest_journeys.started_guest_journeys
|
||||||
|
as incompletion_rate_guest_journey,
|
||||||
|
cast(guest_journeys_with_payment.guest_journeys_with_payment as decimal)
|
||||||
|
/ completed_guest_journeys.completed_guest_journeys
|
||||||
|
as payment_rate_guest_journey,
|
||||||
|
|
||||||
-- DEALS --
|
-- DEALS --
|
||||||
deals.new_deals,
|
deals.new_deals,
|
||||||
|
|
@ -124,10 +232,10 @@ with
|
||||||
|
|
||||||
-- GUEST REVENUE AND PAYMENTS WEIGHTED METRICS --
|
-- GUEST REVENUE AND PAYMENTS WEIGHTED METRICS --
|
||||||
guest_payments.total_guest_payments_in_gbp / nullif(
|
guest_payments.total_guest_payments_in_gbp / nullif(
|
||||||
guest_journeys.completed_guest_journeys, 0
|
completed_guest_journeys.completed_guest_journeys, 0
|
||||||
) as guest_payments_per_completed_guest_journey,
|
) as guest_payments_per_completed_guest_journey,
|
||||||
guest_payments.total_guest_payments_in_gbp / nullif(
|
guest_payments.total_guest_payments_in_gbp / nullif(
|
||||||
guest_journeys.paid_guest_journeys, 0
|
guest_journeys_with_payment.guest_journeys_with_payment, 0
|
||||||
) as guest_payments_per_paid_guest_journey,
|
) as guest_payments_per_paid_guest_journey,
|
||||||
|
|
||||||
-- TOTAL REVENUE WEIGHTED METRICS --
|
-- TOTAL REVENUE WEIGHTED METRICS --
|
||||||
|
|
@ -143,7 +251,7 @@ with
|
||||||
+ coalesce(invoicing.xero_operator_net_fees_in_gbp, 0)
|
+ coalesce(invoicing.xero_operator_net_fees_in_gbp, 0)
|
||||||
+ coalesce(invoicing.xero_apis_net_fees_in_gbp, 0)
|
+ coalesce(invoicing.xero_apis_net_fees_in_gbp, 0)
|
||||||
) / nullif(
|
) / nullif(
|
||||||
guest_journeys.created_guest_journeys, 0
|
created_guest_journeys.created_guest_journeys, 0
|
||||||
) as total_revenue_per_created_guest_journey,
|
) as total_revenue_per_created_guest_journey,
|
||||||
(
|
(
|
||||||
coalesce(guest_payments.total_guest_payments_in_gbp, 0)
|
coalesce(guest_payments.total_guest_payments_in_gbp, 0)
|
||||||
|
|
@ -167,30 +275,45 @@ with
|
||||||
|
|
||||||
from int_dates_mtd_by_dimension d
|
from int_dates_mtd_by_dimension d
|
||||||
left join
|
left join
|
||||||
int_core__mtd_created_bookings_metric created_bookings
|
created_bookings
|
||||||
on d.date = created_bookings.date
|
on d.date = created_bookings.end_date
|
||||||
and d.dimension = created_bookings.dimension
|
and d.dimension = created_bookings.dimension
|
||||||
and d.dimension_value = created_bookings.dimension_value
|
and d.dimension_value = created_bookings.dimension_value
|
||||||
left join
|
left join
|
||||||
int_core__mtd_check_out_bookings_metric check_out_bookings
|
check_out_bookings
|
||||||
on d.date = check_out_bookings.date
|
on d.date = check_out_bookings.end_date
|
||||||
and d.dimension = check_out_bookings.dimension
|
and d.dimension = check_out_bookings.dimension
|
||||||
and d.dimension_value = check_out_bookings.dimension_value
|
and d.dimension_value = check_out_bookings.dimension_value
|
||||||
left join
|
left join
|
||||||
int_core__mtd_cancelled_bookings_metric cancelled_bookings
|
cancelled_bookings
|
||||||
on d.date = cancelled_bookings.date
|
on d.date = cancelled_bookings.end_date
|
||||||
and d.dimension = cancelled_bookings.dimension
|
and d.dimension = cancelled_bookings.dimension
|
||||||
and d.dimension_value = cancelled_bookings.dimension_value
|
and d.dimension_value = cancelled_bookings.dimension_value
|
||||||
left join
|
left join
|
||||||
int_core__mtd_billable_bookings_metric billable_bookings
|
billable_bookings
|
||||||
on d.date = billable_bookings.date
|
on d.date = billable_bookings.end_date
|
||||||
and d.dimension = billable_bookings.dimension
|
and d.dimension = billable_bookings.dimension
|
||||||
and d.dimension_value = billable_bookings.dimension_value
|
and d.dimension_value = billable_bookings.dimension_value
|
||||||
left join
|
left join
|
||||||
int_core__mtd_guest_journey_metrics guest_journeys
|
created_guest_journeys
|
||||||
on d.date = guest_journeys.date
|
on d.date = created_guest_journeys.end_date
|
||||||
and d.dimension = guest_journeys.dimension
|
and d.dimension = created_guest_journeys.dimension
|
||||||
and d.dimension_value = guest_journeys.dimension_value
|
and d.dimension_value = created_guest_journeys.dimension_value
|
||||||
|
left join
|
||||||
|
started_guest_journeys
|
||||||
|
on d.date = started_guest_journeys.end_date
|
||||||
|
and d.dimension = started_guest_journeys.dimension
|
||||||
|
and d.dimension_value = started_guest_journeys.dimension_value
|
||||||
|
left join
|
||||||
|
completed_guest_journeys
|
||||||
|
on d.date = completed_guest_journeys.end_date
|
||||||
|
and d.dimension = completed_guest_journeys.dimension
|
||||||
|
and d.dimension_value = completed_guest_journeys.dimension_value
|
||||||
|
left join
|
||||||
|
guest_journeys_with_payment
|
||||||
|
on d.date = guest_journeys_with_payment.end_date
|
||||||
|
and d.dimension = guest_journeys_with_payment.dimension
|
||||||
|
and d.dimension_value = guest_journeys_with_payment.dimension_value
|
||||||
left join
|
left join
|
||||||
int_core__mtd_accommodation_metrics accommodations
|
int_core__mtd_accommodation_metrics accommodations
|
||||||
on d.date = accommodations.date
|
on d.date = accommodations.date
|
||||||
|
|
@ -202,8 +325,8 @@ with
|
||||||
and d.dimension = deals.dimension
|
and d.dimension = deals.dimension
|
||||||
and d.dimension_value = deals.dimension_value
|
and d.dimension_value = deals.dimension_value
|
||||||
left join
|
left join
|
||||||
int_core__mtd_guest_payments_metrics guest_payments
|
guest_payments
|
||||||
on d.date = guest_payments.date
|
on d.date = guest_payments.end_date
|
||||||
and d.dimension = guest_payments.dimension
|
and d.dimension = guest_payments.dimension
|
||||||
and d.dimension_value = guest_payments.dimension_value
|
and d.dimension_value = guest_payments.dimension_value
|
||||||
left join
|
left join
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue