Update mtd_aggregated_metrics
This commit is contained in:
parent
2c17df3742
commit
54af8af30e
4 changed files with 63 additions and 56 deletions
|
|
@ -11,7 +11,7 @@ with
|
|||
select * from {{ ref("int_core__verification_requests") }}
|
||||
),
|
||||
int_core__verification_payments as (
|
||||
select * from {{ ref("int_core__verification_payments") }}
|
||||
select * from {{ ref("int_core__verification_payments", version=2) }}
|
||||
),
|
||||
int_core__user_host as (select * from {{ ref("int_core__user_host") }}),
|
||||
int_core__mtd_accommodation_segmentation as (
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ This model provides Month-To-Date (MTD) based on Guest Revenue metrics.
|
|||
{{ config(materialized="table", unique_key=["date", "dimension", "dimension_value"]) }}
|
||||
with
|
||||
int_core__verification_payments as (
|
||||
select * from {{ ref("int_core__verification_payments") }}
|
||||
select * from {{ ref("int_core__verification_payments", version=2) }}
|
||||
),
|
||||
int_core__verification_requests as (
|
||||
select * from {{ ref("int_core__verification_requests") }}
|
||||
|
|
@ -37,28 +37,28 @@ with
|
|||
when
|
||||
upper(vp.verification_payment_type)
|
||||
in {{ deposit_fees_verification_payment_type_items }}
|
||||
then vp.amount_in_gbp
|
||||
then vp.amount_without_taxes_in_gbp
|
||||
else null
|
||||
end
|
||||
) as deposit_fees_in_gbp,
|
||||
) as deposit_fees_without_taxes_in_gbp,
|
||||
sum(
|
||||
case
|
||||
when
|
||||
upper(vp.verification_payment_type)
|
||||
in {{ waiver_fees_verification_payment_type_items }}
|
||||
then vp.amount_in_gbp
|
||||
then vp.amount_without_taxes_in_gbp
|
||||
else null
|
||||
end
|
||||
) as waiver_payments_in_gbp,
|
||||
) as waiver_payments_without_taxes_in_gbp,
|
||||
sum(
|
||||
case
|
||||
when
|
||||
upper(vp.verification_payment_type)
|
||||
in {{ checkin_cover_fees_verification_payment_type_items }}
|
||||
then vp.amount_in_gbp
|
||||
then vp.amount_without_taxes_in_gbp
|
||||
else null
|
||||
end
|
||||
) as checkin_cover_fees_in_gbp
|
||||
) as checkin_cover_fees_without_taxes_in_gbp
|
||||
from int_dates_mtd d
|
||||
inner join
|
||||
int_core__verification_payments vp
|
||||
|
|
@ -94,15 +94,21 @@ select
|
|||
d.dimension_value,
|
||||
d.is_end_of_month,
|
||||
d.is_current_month,
|
||||
nullif(gpym.deposit_fees_in_gbp, 0) as deposit_fees_in_gbp,
|
||||
nullif(gpym.waiver_payments_in_gbp, 0) as waiver_payments_in_gbp,
|
||||
nullif(gpym.checkin_cover_fees_in_gbp, 0) as checkin_cover_fees_in_gbp,
|
||||
nullif(
|
||||
coalesce(gpym.deposit_fees_in_gbp, 0)
|
||||
+ coalesce(gpym.waiver_payments_in_gbp, 0)
|
||||
+ coalesce(gpym.checkin_cover_fees_in_gbp, 0),
|
||||
gpym.deposit_fees_without_taxes_in_gbp, 0
|
||||
) as deposit_fees_without_taxes_in_gbp,
|
||||
nullif(
|
||||
gpym.waiver_payments_without_taxes_in_gbp, 0
|
||||
) as waiver_payments_without_taxes_in_gbp,
|
||||
nullif(
|
||||
gpym.checkin_cover_fees_without_taxes_in_gbp, 0
|
||||
) as checkin_cover_fees_without_taxes_in_gbp,
|
||||
nullif(
|
||||
coalesce(gpym.deposit_fees_without_taxes_in_gbp, 0)
|
||||
+ coalesce(gpym.waiver_payments_without_taxes_in_gbp, 0)
|
||||
+ coalesce(gpym.checkin_cover_fees_without_taxes_in_gbp, 0),
|
||||
0
|
||||
) as total_guest_payments_in_gbp
|
||||
) as total_guest_payments_without_taxes_in_gbp
|
||||
from int_dates_mtd_by_dimension d
|
||||
left join
|
||||
guest_payments_year_month gpym
|
||||
|
|
|
|||
|
|
@ -362,18 +362,18 @@
|
|||
{
|
||||
"order_by": 260,
|
||||
"metric": "Deposit Fees",
|
||||
"value": "deposit_fees_in_gbp",
|
||||
"previous_year_value": "previous_year_deposit_fees_in_gbp",
|
||||
"relative_increment": "relative_increment_deposit_fees_in_gbp",
|
||||
"value": "deposit_fees_without_taxes_in_gbp",
|
||||
"previous_year_value": "previous_year_deposit_fees_without_taxes_in_gbp",
|
||||
"relative_increment": "relative_increment_deposit_fees_without_taxes_in_gbp",
|
||||
"number_format": "currency_gbp",
|
||||
"increment_sign_format": "positive",
|
||||
},
|
||||
{
|
||||
"order_by": 262,
|
||||
"metric": "Waiver Amount Paid by Guests",
|
||||
"value": "waiver_payments_in_gbp",
|
||||
"previous_year_value": "previous_year_waiver_payments_in_gbp",
|
||||
"relative_increment": "relative_increment_waiver_payments_in_gbp",
|
||||
"value": "waiver_payments_without_taxes_in_gbp",
|
||||
"previous_year_value": "previous_year_waiver_payments_without_taxes_in_gbp",
|
||||
"relative_increment": "relative_increment_waiver_payments_without_taxes_in_gbp",
|
||||
"number_format": "currency_gbp",
|
||||
"increment_sign_format": "positive",
|
||||
},
|
||||
|
|
@ -398,9 +398,9 @@
|
|||
{
|
||||
"order_by": 265,
|
||||
"metric": "Check-In Hero Amount Paid by Guests",
|
||||
"value": "checkin_cover_fees_in_gbp",
|
||||
"previous_year_value": "previous_year_checkin_cover_fees_in_gbp",
|
||||
"relative_increment": "relative_increment_checkin_cover_fees_in_gbp",
|
||||
"value": "checkin_cover_fees_without_taxes_in_gbp",
|
||||
"previous_year_value": "previous_year_checkin_cover_fees_without_taxes_in_gbp",
|
||||
"relative_increment": "relative_increment_checkin_cover_fees_without_taxes_in_gbp",
|
||||
"number_format": "currency_gbp",
|
||||
"increment_sign_format": "positive",
|
||||
},
|
||||
|
|
@ -416,9 +416,9 @@
|
|||
{
|
||||
"order_by": 290,
|
||||
"metric": "Guest Payments",
|
||||
"value": "total_guest_payments_in_gbp",
|
||||
"previous_year_value": "previous_year_total_guest_payments_in_gbp",
|
||||
"relative_increment": "relative_increment_total_guest_payments_in_gbp",
|
||||
"value": "total_guest_payments_without_taxes_in_gbp",
|
||||
"previous_year_value": "previous_year_total_guest_payments_without_taxes_in_gbp",
|
||||
"relative_increment": "relative_increment_total_guest_payments_without_taxes_in_gbp",
|
||||
"number_format": "currency_gbp",
|
||||
"increment_sign_format": "positive",
|
||||
},
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
This model pivots the data of the different mtd metrics models to get
|
||||
previous year for each line & computing relative increment. --
|
||||
*/
|
||||
|
||||
{{ config(materialized="table", unique_key=["date", "dimension", "dimension_value"]) }}
|
||||
with
|
||||
int_core__mtd_booking_metrics as (
|
||||
|
|
@ -23,7 +22,9 @@ with
|
|||
int_xero__mtd_invoicing_metrics as (
|
||||
select * from {{ ref("int_xero__mtd_invoicing_metrics") }}
|
||||
),
|
||||
int_dates_mtd_by_dimension as (select * from {{ ref("int_dates_mtd_by_dimension") }}),
|
||||
int_dates_mtd_by_dimension as (
|
||||
select * from {{ ref("int_dates_mtd_by_dimension") }}
|
||||
),
|
||||
|
||||
plain_kpi_combination as (
|
||||
|
||||
|
|
@ -94,25 +95,25 @@ with
|
|||
invoicing.xero_host_resolution_payment_count,
|
||||
|
||||
-- GUEST REVENUE AND PAYMENTS --
|
||||
guest_payments.deposit_fees_in_gbp,
|
||||
guest_payments.waiver_payments_in_gbp,
|
||||
guest_payments.deposit_fees_without_taxes_in_gbp,
|
||||
guest_payments.waiver_payments_without_taxes_in_gbp,
|
||||
invoicing.xero_waiver_paid_back_to_host_in_gbp,
|
||||
nullif(
|
||||
coalesce(guest_payments.waiver_payments_in_gbp, 0)
|
||||
coalesce(guest_payments.waiver_payments_without_taxes_in_gbp, 0)
|
||||
+ coalesce(invoicing.xero_waiver_paid_back_to_host_in_gbp, 0),
|
||||
0
|
||||
) as waiver_net_fees_in_gbp,
|
||||
guest_payments.checkin_cover_fees_in_gbp,
|
||||
guest_payments.total_guest_payments_in_gbp,
|
||||
guest_payments.checkin_cover_fees_without_taxes_in_gbp,
|
||||
guest_payments.total_guest_payments_without_taxes_in_gbp,
|
||||
nullif(
|
||||
coalesce(guest_payments.total_guest_payments_in_gbp, 0)
|
||||
coalesce(guest_payments.total_guest_payments_without_taxes_in_gbp, 0)
|
||||
+ coalesce(invoicing.xero_waiver_paid_back_to_host_in_gbp, 0),
|
||||
0
|
||||
) as total_guest_revenue_in_gbp,
|
||||
|
||||
-- TOTAL REVENUE --
|
||||
nullif(
|
||||
coalesce(guest_payments.total_guest_payments_in_gbp, 0)
|
||||
coalesce(guest_payments.total_guest_payments_without_taxes_in_gbp, 0)
|
||||
+ coalesce(invoicing.xero_waiver_paid_back_to_host_in_gbp, 0)
|
||||
+ coalesce(invoicing.xero_operator_net_fees_in_gbp, 0)
|
||||
+ coalesce(invoicing.xero_apis_net_fees_in_gbp, 0),
|
||||
|
|
@ -120,21 +121,21 @@ with
|
|||
) as total_revenue_in_gbp,
|
||||
|
||||
-- GUEST REVENUE AND PAYMENTS WEIGHTED METRICS --
|
||||
guest_payments.total_guest_payments_in_gbp / nullif(
|
||||
guest_payments.total_guest_payments_without_taxes_in_gbp / nullif(
|
||||
guest_journeys.completed_guest_journeys, 0
|
||||
) as guest_payments_per_completed_guest_journey,
|
||||
guest_payments.total_guest_payments_in_gbp / nullif(
|
||||
guest_payments.total_guest_payments_without_taxes_in_gbp / nullif(
|
||||
guest_journeys.paid_guest_journeys, 0
|
||||
) as guest_payments_per_paid_guest_journey,
|
||||
nullif(
|
||||
coalesce(guest_payments.total_guest_payments_in_gbp, 0)
|
||||
coalesce(guest_payments.total_guest_payments_without_taxes_in_gbp, 0)
|
||||
+ coalesce(invoicing.xero_waiver_paid_back_to_host_in_gbp, 0),
|
||||
0
|
||||
) / nullif(
|
||||
guest_journeys.completed_guest_journeys, 0
|
||||
) as guest_revenue_per_completed_guest_journey,
|
||||
nullif(
|
||||
coalesce(guest_payments.total_guest_payments_in_gbp, 0)
|
||||
coalesce(guest_payments.total_guest_payments_without_taxes_in_gbp, 0)
|
||||
+ coalesce(invoicing.xero_waiver_paid_back_to_host_in_gbp, 0),
|
||||
0
|
||||
) / nullif(
|
||||
|
|
@ -143,14 +144,14 @@ with
|
|||
|
||||
-- TOTAL REVENUE WEIGHTED METRICS --
|
||||
(
|
||||
coalesce(guest_payments.total_guest_payments_in_gbp, 0)
|
||||
coalesce(guest_payments.total_guest_payments_without_taxes_in_gbp, 0)
|
||||
+ coalesce(invoicing.xero_waiver_paid_back_to_host_in_gbp, 0)
|
||||
+ coalesce(invoicing.xero_operator_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,
|
||||
(
|
||||
coalesce(guest_payments.total_guest_payments_in_gbp, 0)
|
||||
coalesce(guest_payments.total_guest_payments_without_taxes_in_gbp, 0)
|
||||
+ coalesce(invoicing.xero_waiver_paid_back_to_host_in_gbp, 0)
|
||||
+ coalesce(invoicing.xero_operator_net_fees_in_gbp, 0)
|
||||
+ coalesce(invoicing.xero_apis_net_fees_in_gbp, 0)
|
||||
|
|
@ -158,7 +159,7 @@ with
|
|||
guest_journeys.created_guest_journeys, 0
|
||||
) as total_revenue_per_created_guest_journey,
|
||||
(
|
||||
coalesce(guest_payments.total_guest_payments_in_gbp, 0)
|
||||
coalesce(guest_payments.total_guest_payments_without_taxes_in_gbp, 0)
|
||||
+ coalesce(invoicing.xero_waiver_paid_back_to_host_in_gbp, 0)
|
||||
+ coalesce(invoicing.xero_operator_net_fees_in_gbp, 0)
|
||||
+ coalesce(invoicing.xero_apis_net_fees_in_gbp, 0)
|
||||
|
|
@ -166,7 +167,7 @@ with
|
|||
deals.deals_booked_in_month, 0
|
||||
) as total_revenue_per_deals_booked_in_month,
|
||||
(
|
||||
coalesce(guest_payments.total_guest_payments_in_gbp, 0)
|
||||
coalesce(guest_payments.total_guest_payments_without_taxes_in_gbp, 0)
|
||||
+ coalesce(invoicing.xero_waiver_paid_back_to_host_in_gbp, 0)
|
||||
+ coalesce(invoicing.xero_operator_net_fees_in_gbp, 0)
|
||||
+ coalesce(invoicing.xero_apis_net_fees_in_gbp, 0)
|
||||
|
|
@ -175,8 +176,8 @@ with
|
|||
) as total_revenue_per_listings_booked_in_month
|
||||
|
||||
from int_dates_mtd_by_dimension d
|
||||
left join
|
||||
int_core__mtd_booking_metrics bookings
|
||||
left join
|
||||
int_core__mtd_booking_metrics bookings
|
||||
on d.date = bookings.date
|
||||
and d.dimension = bookings.dimension
|
||||
and d.dimension_value = bookings.dimension_value
|
||||
|
|
@ -190,18 +191,18 @@ with
|
|||
on d.date = accommodations.date
|
||||
and d.dimension = accommodations.dimension
|
||||
and d.dimension_value = accommodations.dimension_value
|
||||
left join
|
||||
int_core__mtd_deal_metrics deals
|
||||
left join
|
||||
int_core__mtd_deal_metrics deals
|
||||
on d.date = deals.date
|
||||
and d.dimension = deals.dimension
|
||||
and d.dimension_value = deals.dimension_value
|
||||
left join
|
||||
int_core__mtd_guest_payments_metrics guest_payments
|
||||
int_core__mtd_guest_payments_metrics guest_payments
|
||||
on d.date = guest_payments.date
|
||||
and d.dimension = guest_payments.dimension
|
||||
and d.dimension_value = guest_payments.dimension_value
|
||||
left join
|
||||
int_xero__mtd_invoicing_metrics invoicing
|
||||
left join
|
||||
int_xero__mtd_invoicing_metrics invoicing
|
||||
on d.date = invoicing.date
|
||||
and d.dimension = invoicing.dimension
|
||||
and d.dimension_value = invoicing.dimension_value
|
||||
|
|
@ -274,12 +275,12 @@ select
|
|||
{{ calculate_safe_relative_increment("xero_host_resolution_payment_count") }},
|
||||
|
||||
-- GUEST REVENUE AND PAYMENTS --
|
||||
{{ calculate_safe_relative_increment("deposit_fees_in_gbp") }},
|
||||
{{ calculate_safe_relative_increment("waiver_payments_in_gbp") }},
|
||||
{{ calculate_safe_relative_increment("deposit_fees_without_taxes_in_gbp") }},
|
||||
{{ calculate_safe_relative_increment("waiver_payments_without_taxes_in_gbp") }},
|
||||
{{ calculate_safe_relative_increment("xero_waiver_paid_back_to_host_in_gbp") }},
|
||||
{{ calculate_safe_relative_increment("waiver_net_fees_in_gbp") }},
|
||||
{{ calculate_safe_relative_increment("checkin_cover_fees_in_gbp") }},
|
||||
{{ calculate_safe_relative_increment("total_guest_payments_in_gbp") }},
|
||||
{{ calculate_safe_relative_increment("checkin_cover_fees_without_taxes_in_gbp") }},
|
||||
{{ calculate_safe_relative_increment("total_guest_payments_without_taxes_in_gbp") }},
|
||||
{{ calculate_safe_relative_increment("total_guest_revenue_in_gbp") }},
|
||||
|
||||
-- TOTAL REVENUE --
|
||||
|
|
@ -308,7 +309,7 @@ select
|
|||
from plain_kpi_combination current
|
||||
left join
|
||||
plain_kpi_combination previous_year
|
||||
on current.dimension = previous_year.dimension
|
||||
on current.dimension = previous_year.dimension
|
||||
and current.dimension_value = previous_year.dimension_value
|
||||
and current.month = previous_year.month
|
||||
and current.year = previous_year.year + 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue