Merged PR 2257: Expose guest revenue and guest journey payment metrics
This PR aims to expose the new metrics to the business KPIs report. The new metrics exposed are, for the global and the by deal view: - Guest Revenue - Guest Revenue per Guest Journey Completed - Guest Revenue per Guest Journey with Payment - Guest Payments - Guest Payments per Guest Journey Completed - Guest Payments per Guest Journey with Payment - Guest Journey with Payment - Guest Journey Payment Rate Changes: - Silly change on the naming in the by deal view of `payment_rate_guest_journey` to be consistent with the global view. - Silly change that I miss some GJ payment metric for the view by deal id. - Added a new number format called `currency_gbp` - only for monetary metrics, available in the schema files - Usual procedure to publish metrics: for global metrics, add them in the `int_mtd_aggregated_metrics`. I also changed the order of display. - **Important**: to avoid displaying revenue figures until Xero invoicing is handled, I created a macro called `is_date_before_previous_month` that is called in the reporting equivalent models: `mtd_aggregated_metrics` in the where section and in the `monthly_aggregated_metrics_history_by_deal` as a case-when. This should allow to expose all new metrics, and enable the publishing of a new update of the business kpis! Related work items: #18107
This commit is contained in:
parent
d39bc02ae1
commit
3b75d9eefb
8 changed files with 171 additions and 39 deletions
18
macros/is_date_before_previous_month.sql
Normal file
18
macros/is_date_before_previous_month.sql
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
This macro provides a boolean answer to the question:
|
||||
- Is this date before the previous month?
|
||||
The computation is based on the current date by using now()
|
||||
|
||||
Inputs:
|
||||
- date: the date from which you want to check
|
||||
Output:
|
||||
- boolean; true for is before the previous month
|
||||
false for is not before the previous month
|
||||
*/
|
||||
{% macro is_date_before_previous_month(date) %}
|
||||
(
|
||||
date_trunc('month', ({{ date }})::date)::date
|
||||
+ interval '1 month'
|
||||
)::date
|
||||
< date_trunc('month', now())::date
|
||||
{% endmacro %}
|
||||
|
|
@ -81,7 +81,7 @@ with
|
|||
cast(sym.started_guest_journeys as decimal)/cym.created_guest_journeys as start_rate_guest_journey,
|
||||
cast(coym.completed_guest_journeys as decimal)/sym.started_guest_journeys as completion_rate_guest_journey,
|
||||
1-cast(coym.completed_guest_journeys as decimal)/sym.started_guest_journeys as incompletion_rate_guest_journey,
|
||||
cast(pym.paid_guest_journeys as decimal)/coym.completed_guest_journeys as paid_rate_guest_journey
|
||||
cast(pym.paid_guest_journeys as decimal)/coym.completed_guest_journeys as payment_rate_guest_journey
|
||||
from int_dates_by_deal d
|
||||
left join created_year_month cym
|
||||
on d.first_day_month = cym.first_day_month
|
||||
|
|
|
|||
|
|
@ -24,10 +24,11 @@ select
|
|||
gj.created_guest_journeys,
|
||||
gj.started_guest_journeys,
|
||||
gj.completed_guest_journeys,
|
||||
gj.paid_guest_journeys,
|
||||
gj.start_rate_guest_journey,
|
||||
gj.completion_rate_guest_journey,
|
||||
gj.incompletion_rate_guest_journey,
|
||||
gj.paid_guest_journeys,
|
||||
gj.payment_rate_guest_journey,
|
||||
a.new_listings,
|
||||
a.first_time_booked_listings,
|
||||
a.churning_listings,
|
||||
|
|
|
|||
|
|
@ -49,6 +49,14 @@
|
|||
},
|
||||
{
|
||||
"order_by": 7,
|
||||
"metric": "Guest Journey with Payment",
|
||||
"value": "paid_guest_journeys",
|
||||
"previous_year_value": "previous_year_paid_guest_journeys",
|
||||
"relative_increment": "relative_increment_paid_guest_journeys",
|
||||
"number_format": "integer",
|
||||
},
|
||||
{
|
||||
"order_by": 8,
|
||||
"metric": "New Deals",
|
||||
"value": "new_deals",
|
||||
"previous_year_value": "previous_year_new_deals",
|
||||
|
|
@ -56,7 +64,7 @@
|
|||
"number_format": "integer",
|
||||
},
|
||||
{
|
||||
"order_by": 8,
|
||||
"order_by": 9,
|
||||
"metric": "First Time Booked Deals",
|
||||
"value": "first_time_booked_deals",
|
||||
"previous_year_value": "previous_year_first_time_booked_deals",
|
||||
|
|
@ -64,7 +72,7 @@
|
|||
"number_format": "integer",
|
||||
},
|
||||
{
|
||||
"order_by": 9,
|
||||
"order_by": 10,
|
||||
"metric": "Deals Booked in Month",
|
||||
"value": "deals_booked_in_month",
|
||||
"previous_year_value": "previous_year_deals_booked_in_month",
|
||||
|
|
@ -72,7 +80,7 @@
|
|||
"number_format": "integer",
|
||||
},
|
||||
{
|
||||
"order_by": 10,
|
||||
"order_by": 11,
|
||||
"metric": "Deals Booked in 6 Months",
|
||||
"value": "deals_booked_in_6_months",
|
||||
"previous_year_value": "previous_year_deals_booked_in_6_months",
|
||||
|
|
@ -80,7 +88,7 @@
|
|||
"number_format": "integer",
|
||||
},
|
||||
{
|
||||
"order_by": 11,
|
||||
"order_by": 12,
|
||||
"metric": "Deals Booked in 12 Months",
|
||||
"value": "deals_booked_in_12_months",
|
||||
"previous_year_value": "previous_year_deals_booked_in_12_months",
|
||||
|
|
@ -88,7 +96,7 @@
|
|||
"number_format": "integer",
|
||||
},
|
||||
{
|
||||
"order_by": 12,
|
||||
"order_by": 13,
|
||||
"metric": "Churning Deals",
|
||||
"value": "churning_deals",
|
||||
"previous_year_value": "previous_year_churning_deals",
|
||||
|
|
@ -96,7 +104,7 @@
|
|||
"number_format": "integer",
|
||||
},
|
||||
{
|
||||
"order_by": 13,
|
||||
"order_by": 14,
|
||||
"metric": "New Listings",
|
||||
"value": "new_listings",
|
||||
"previous_year_value": "previous_year_new_listings",
|
||||
|
|
@ -104,7 +112,7 @@
|
|||
"number_format": "integer",
|
||||
},
|
||||
{
|
||||
"order_by": 14,
|
||||
"order_by": 15,
|
||||
"metric": "First Time Booked Listings",
|
||||
"value": "first_time_booked_listings",
|
||||
"previous_year_value": "previous_year_first_time_booked_listings",
|
||||
|
|
@ -112,7 +120,7 @@
|
|||
"number_format": "integer",
|
||||
},
|
||||
{
|
||||
"order_by": 15,
|
||||
"order_by": 16,
|
||||
"metric": "Listings Booked in Month",
|
||||
"value": "listings_booked_in_month",
|
||||
"previous_year_value": "previous_year_listings_booked_in_month",
|
||||
|
|
@ -120,7 +128,7 @@
|
|||
"number_format": "integer",
|
||||
},
|
||||
{
|
||||
"order_by": 16,
|
||||
"order_by": 17,
|
||||
"metric": "Listings Booked in 6 Months",
|
||||
"value": "listings_booked_in_6_months",
|
||||
"previous_year_value": "previous_year_listings_booked_in_6_months",
|
||||
|
|
@ -128,7 +136,7 @@
|
|||
"number_format": "integer",
|
||||
},
|
||||
{
|
||||
"order_by": 17,
|
||||
"order_by": 18,
|
||||
"metric": "Listings Booked in 12 Months",
|
||||
"value": "listings_booked_in_12_months",
|
||||
"previous_year_value": "previous_year_listings_booked_in_12_months",
|
||||
|
|
@ -136,7 +144,7 @@
|
|||
"number_format": "integer",
|
||||
},
|
||||
{
|
||||
"order_by": 18,
|
||||
"order_by": 19,
|
||||
"metric": "Churning Listings",
|
||||
"value": "churning_listings",
|
||||
"previous_year_value": "previous_year_churning_listings",
|
||||
|
|
@ -144,7 +152,7 @@
|
|||
"number_format": "integer",
|
||||
},
|
||||
{
|
||||
"order_by": 19,
|
||||
"order_by": 100,
|
||||
"metric": "Guest Journey Start Rate",
|
||||
"value": "start_rate_guest_journey",
|
||||
"previous_year_value": "previous_year_start_rate_guest_journey",
|
||||
|
|
@ -152,7 +160,7 @@
|
|||
"number_format": "percentage",
|
||||
},
|
||||
{
|
||||
"order_by": 20,
|
||||
"order_by": 101,
|
||||
"metric": "Guest Journey Completion Rate",
|
||||
"value": "completion_rate_guest_journey",
|
||||
"previous_year_value": "previous_year_completion_rate_guest_journey",
|
||||
|
|
@ -160,13 +168,69 @@
|
|||
"number_format": "percentage",
|
||||
},
|
||||
{
|
||||
"order_by": 21,
|
||||
"order_by": 102,
|
||||
"metric": "Guest Journey Incompletion Rate",
|
||||
"value": "incompletion_rate_guest_journey",
|
||||
"previous_year_value": "previous_year_incompletion_rate_guest_journey",
|
||||
"relative_increment": "relative_increment_incompletion_rate_guest_journey",
|
||||
"number_format": "percentage",
|
||||
},
|
||||
{
|
||||
"order_by": 103,
|
||||
"metric": "Guest Journey Payment Rate",
|
||||
"value": "payment_rate_guest_journey",
|
||||
"previous_year_value": "previous_year_payment_rate_guest_journey",
|
||||
"relative_increment": "relative_increment_payment_rate_guest_journey",
|
||||
"number_format": "percentage",
|
||||
},
|
||||
{
|
||||
"order_by": 200,
|
||||
"metric": "Guest Payments (GBP)",
|
||||
"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",
|
||||
"number_format": "currency_gbp",
|
||||
},
|
||||
{
|
||||
"order_by": 201,
|
||||
"metric": "Guest Payments per Guest Journey Completed (GBP)",
|
||||
"value": "guest_payments_per_completed_guest_journey",
|
||||
"previous_year_value": "previous_year_guest_payments_per_completed_guest_journey",
|
||||
"relative_increment": "relative_increment_guest_payments_per_completed_guest_journey",
|
||||
"number_format": "currency_gbp",
|
||||
},
|
||||
{
|
||||
"order_by": 202,
|
||||
"metric": "Guest Payments per Guest Journey with Payment (GBP)",
|
||||
"value": "guest_payments_per_paid_guest_journey",
|
||||
"previous_year_value": "previous_year_guest_payments_per_paid_guest_journey",
|
||||
"relative_increment": "relative_increment_guest_payments_per_paid_guest_journey",
|
||||
"number_format": "currency_gbp",
|
||||
},
|
||||
{
|
||||
"order_by": 203,
|
||||
"metric": "Guest Revenue (GBP)",
|
||||
"value": "total_guest_revenue_in_gbp",
|
||||
"previous_year_value": "previous_year_total_guest_revenue_in_gbp",
|
||||
"relative_increment": "relative_increment_total_guest_revenue_in_gbp",
|
||||
"number_format": "currency_gbp",
|
||||
},
|
||||
{
|
||||
"order_by": 204,
|
||||
"metric": "Guest Revenue per Guest Journey Completed (GBP)",
|
||||
"value": "guest_revenue_per_completed_guest_journey",
|
||||
"previous_year_value": "previous_year_guest_revenue_per_completed_guest_journey",
|
||||
"relative_increment": "relative_increment_guest_revenue_per_completed_guest_journey",
|
||||
"number_format": "currency_gbp",
|
||||
},
|
||||
{
|
||||
"order_by": 205,
|
||||
"metric": "Guest Revenue per Guest Journey with Payment (GBP)",
|
||||
"value": "guest_revenue_per_paid_guest_journey",
|
||||
"previous_year_value": "previous_year_guest_revenue_per_paid_guest_journey",
|
||||
"relative_increment": "relative_increment_guest_revenue_per_paid_guest_journey",
|
||||
"number_format": "currency_gbp",
|
||||
}
|
||||
] %}
|
||||
with
|
||||
int_mtd_vs_previous_year_metrics as (
|
||||
|
|
|
|||
|
|
@ -267,7 +267,7 @@ models:
|
|||
description: allows for grouping and formatting for displaying purposes.
|
||||
tests:
|
||||
- accepted_values:
|
||||
values: ['integer', 'percentage']
|
||||
values: ['integer', 'percentage', 'currency_gbp']
|
||||
|
||||
- name: value
|
||||
data_type: numeric
|
||||
|
|
|
|||
|
|
@ -4,25 +4,49 @@ with
|
|||
)
|
||||
|
||||
select
|
||||
year as year,
|
||||
month as month,
|
||||
day as day,
|
||||
date as date,
|
||||
id_deal as id_deal,
|
||||
deal_lifecycle_state as deal_lifecycle_state,
|
||||
created_bookings as created_bookings,
|
||||
check_out_bookings as check_out_bookings,
|
||||
cancelled_bookings as cancelled_bookings,
|
||||
created_guest_journeys as created_guest_journeys,
|
||||
started_guest_journeys as started_guest_journeys,
|
||||
completed_guest_journeys as completed_guest_journeys,
|
||||
start_rate_guest_journey as start_rate_guest_journey,
|
||||
completion_rate_guest_journey as completion_rate_guest_journey,
|
||||
incompletion_rate_guest_journey as incompletion_rate_guest_journey,
|
||||
new_listings as new_listings,
|
||||
first_time_booked_listings as first_time_booked_listings,
|
||||
churning_listings as churning_listings,
|
||||
listings_booked_in_month as listings_booked_in_month,
|
||||
listings_booked_in_6_months as listings_booked_in_6_months,
|
||||
listings_booked_in_12_months as listings_booked_in_12_months
|
||||
year as year,
|
||||
month as month,
|
||||
day as day,
|
||||
date as date,
|
||||
id_deal as id_deal,
|
||||
deal_lifecycle_state as deal_lifecycle_state,
|
||||
created_bookings as created_bookings,
|
||||
check_out_bookings as check_out_bookings,
|
||||
cancelled_bookings as cancelled_bookings,
|
||||
created_guest_journeys as created_guest_journeys,
|
||||
started_guest_journeys as started_guest_journeys,
|
||||
completed_guest_journeys as completed_guest_journeys,
|
||||
paid_guest_journeys as paid_guest_journeys,
|
||||
start_rate_guest_journey as start_rate_guest_journey,
|
||||
completion_rate_guest_journey as completion_rate_guest_journey,
|
||||
incompletion_rate_guest_journey as incompletion_rate_guest_journey,
|
||||
payment_rate_guest_journey as payment_rate_guest_journey,
|
||||
new_listings as new_listings,
|
||||
first_time_booked_listings as first_time_booked_listings,
|
||||
churning_listings as churning_listings,
|
||||
listings_booked_in_month as listings_booked_in_month,
|
||||
listings_booked_in_6_months as listings_booked_in_6_months,
|
||||
listings_booked_in_12_months as listings_booked_in_12_months,
|
||||
total_guest_payments_in_gbp as total_guest_payments_in_gbp,
|
||||
-- Avoid displaying revenue figures until invoicing period finishes
|
||||
case
|
||||
when {{ is_date_before_previous_month("date") }}
|
||||
then total_guest_revenue_in_gbp
|
||||
else null
|
||||
end as total_guest_revenue_in_gbp,
|
||||
guest_payments_per_completed_guest_journey
|
||||
as guest_payments_per_completed_guest_journey,
|
||||
guest_payments_per_paid_guest_journey as guest_payments_per_paid_guest_journey,
|
||||
-- Avoid displaying revenue figures until invoicing period finishes
|
||||
case
|
||||
when {{ is_date_before_previous_month("date") }}
|
||||
then guest_revenue_per_completed_guest_journey
|
||||
else null
|
||||
end as guest_revenue_per_completed_guest_journey,
|
||||
-- Avoid displaying revenue figures until invoicing period finishes
|
||||
case
|
||||
when {{ is_date_before_previous_month("date") }}
|
||||
then guest_revenue_per_paid_guest_journey
|
||||
else null
|
||||
end as guest_revenue_per_paid_guest_journey
|
||||
from int_monthly_aggregated_metrics_history_by_deal
|
||||
|
|
|
|||
|
|
@ -18,3 +18,28 @@ select
|
|||
previous_year_value as previous_year_value,
|
||||
relative_increment as relative_increment
|
||||
from int_mtd_aggregated_metrics
|
||||
/*
|
||||
The following where condition is applied to avoid displaying revenue metrics
|
||||
in the MTD for the current month and the previous month. The main reason is
|
||||
that we have a time delay between when the guest does a payment vs. when we
|
||||
invoice or credit hosts (Xero).
|
||||
This is specially tricky for the Host-takes-waiver revenue: guests payments
|
||||
happen in a timely fashion, and we get all waiver money from the guests. Once
|
||||
the month is finished, Finance will start to invoice hosts, and in this case,
|
||||
all hosts that have the Host-takes-waiver need to be payed back the amount
|
||||
coming from the guest.
|
||||
Not having this filter would mean that, in the current month, the figures
|
||||
displayed of guest revenue would be much larger than they actually will be
|
||||
because we still need to pay back to the hosts these waivers.
|
||||
For a more current-month evaluation, Guest Payments should be a good proxy
|
||||
metric to follow.
|
||||
*/
|
||||
where
|
||||
(
|
||||
-- Not show current + previous month if revenue metric
|
||||
-- we need to pass +1 day to date since it's the last day of the month
|
||||
lower(metric) like '%revenue%'
|
||||
and {{ is_date_before_previous_month("date") }}
|
||||
)
|
||||
-- Keep all history for the rest of metrics
|
||||
or (lower(metric) not like '%revenue%')
|
||||
|
|
|
|||
|
|
@ -377,7 +377,7 @@ models:
|
|||
description: allows for grouping and formatting for displaying purposes.
|
||||
tests:
|
||||
- accepted_values:
|
||||
values: ['integer', 'percentage']
|
||||
values: ['integer', 'percentage', 'currency_gbp']
|
||||
|
||||
- name: value
|
||||
data_type: numeric
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue