Merged PR 2354: Main KPIs batch 2 exposure

This PR exposes the following metrics to the Main KPIs business overview report, for both Global + By Deal view:
- Total Revenue
- Total Revenue per Booking Created
- Total Revenue per Guest Journey Created
- Total Revenue per Deals Booked in Month (does not apply on the by deal view)
- Total Revenue per Listings Booked in Month
- Invoiced Operator Revenue
- Host Resolution Payment Count
- Host Resolution Amount Paid

Keep in mind Global view will be displaying these metrics once this is merged. I also changed a bit the order of the metric display.
Note that Billable Bookings are not included.

I recommend to review by 1) checking the first commit. This is almost the same as the previous abandoned PR that @<Joaquin Ossa> you already checked on Tuesday. I added a second commit, to be checked later, which basically fixes some stupid issues that if one of the source of revenue is null, then total revenue is null. This is specially critical for the view by deal, since most of them do not have revenue from APIs - thus all total revenue figures were null...

Related work items: #18108, #18109, #18110, #18719
This commit is contained in:
Oriol Roqué Paniagua 2024-07-19 09:14:30 +00:00
parent 361ad31299
commit ee13eda5f3
7 changed files with 207 additions and 80 deletions

View file

@ -77,9 +77,12 @@ select
invoicing.xero_host_resolution_payment_count,
-- TOTAL REVENUE --
guest_revenue.total_guest_revenue_in_gbp
+ invoicing.xero_operator_net_fees_in_gbp
+ invoicing.xero_apis_net_fees_in_gbp as total_revenue_in_gbp,
nullif(
coalesce(guest_revenue.total_guest_revenue_in_gbp, 0)
+ coalesce(invoicing.xero_operator_net_fees_in_gbp, 0)
+ coalesce(invoicing.xero_apis_net_fees_in_gbp, 0),
0
) as total_revenue_in_gbp,
-- GUEST REVENUE AND PAYMENTS WEIGHTED METRICS --
guest_revenue.total_guest_payments_in_gbp,
@ -99,22 +102,22 @@ select
-- TOTAL REVENUE WEIGHTED METRICS --
(
guest_revenue.total_guest_revenue_in_gbp
+ invoicing.xero_operator_net_fees_in_gbp
+ invoicing.xero_apis_net_fees_in_gbp
coalesce(guest_revenue.total_guest_revenue_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,
(
guest_revenue.total_guest_revenue_in_gbp
+ invoicing.xero_operator_net_fees_in_gbp
+ invoicing.xero_apis_net_fees_in_gbp
coalesce(guest_revenue.total_guest_revenue_in_gbp, 0)
+ coalesce(invoicing.xero_operator_net_fees_in_gbp, 0)
+ coalesce(invoicing.xero_apis_net_fees_in_gbp, 0)
) / nullif(
guest_journeys.created_guest_journeys, 0
) as total_revenue_per_created_guest_journey,
(
guest_revenue.total_guest_revenue_in_gbp
+ invoicing.xero_operator_net_fees_in_gbp
+ invoicing.xero_apis_net_fees_in_gbp
coalesce(guest_revenue.total_guest_revenue_in_gbp, 0)
+ coalesce(invoicing.xero_operator_net_fees_in_gbp, 0)
+ coalesce(invoicing.xero_apis_net_fees_in_gbp, 0)
) / nullif(
accommodations.listings_booked_in_month, 0
) as total_revenue_per_listings_booked_in_month

View file

@ -32,7 +32,7 @@
"number_format": "integer",
},
{
"order_by": 5,
"order_by": 11,
"metric": "Guest Journey Started",
"value": "started_guest_journeys",
"previous_year_value": "previous_year_started_guest_journeys",
@ -40,7 +40,7 @@
"number_format": "integer",
},
{
"order_by": 6,
"order_by": 12,
"metric": "Guest Journey Completed",
"value": "completed_guest_journeys",
"previous_year_value": "previous_year_completed_guest_journeys",
@ -48,7 +48,7 @@
"number_format": "integer",
},
{
"order_by": 7,
"order_by": 13,
"metric": "Guest Journey with Payment",
"value": "paid_guest_journeys",
"previous_year_value": "previous_year_paid_guest_journeys",
@ -56,7 +56,7 @@
"number_format": "integer",
},
{
"order_by": 8,
"order_by": 20,
"metric": "New Deals",
"value": "new_deals",
"previous_year_value": "previous_year_new_deals",
@ -64,7 +64,7 @@
"number_format": "integer",
},
{
"order_by": 9,
"order_by": 21,
"metric": "First Time Booked Deals",
"value": "first_time_booked_deals",
"previous_year_value": "previous_year_first_time_booked_deals",
@ -72,7 +72,7 @@
"number_format": "integer",
},
{
"order_by": 10,
"order_by": 22,
"metric": "Deals Booked in Month",
"value": "deals_booked_in_month",
"previous_year_value": "previous_year_deals_booked_in_month",
@ -80,7 +80,7 @@
"number_format": "integer",
},
{
"order_by": 11,
"order_by": 23,
"metric": "Deals Booked in 6 Months",
"value": "deals_booked_in_6_months",
"previous_year_value": "previous_year_deals_booked_in_6_months",
@ -88,7 +88,7 @@
"number_format": "integer",
},
{
"order_by": 12,
"order_by": 24,
"metric": "Deals Booked in 12 Months",
"value": "deals_booked_in_12_months",
"previous_year_value": "previous_year_deals_booked_in_12_months",
@ -96,7 +96,7 @@
"number_format": "integer",
},
{
"order_by": 13,
"order_by": 25,
"metric": "Churning Deals",
"value": "churning_deals",
"previous_year_value": "previous_year_churning_deals",
@ -104,7 +104,7 @@
"number_format": "integer",
},
{
"order_by": 14,
"order_by": 30,
"metric": "New Listings",
"value": "new_listings",
"previous_year_value": "previous_year_new_listings",
@ -112,7 +112,7 @@
"number_format": "integer",
},
{
"order_by": 15,
"order_by": 31,
"metric": "First Time Booked Listings",
"value": "first_time_booked_listings",
"previous_year_value": "previous_year_first_time_booked_listings",
@ -120,7 +120,7 @@
"number_format": "integer",
},
{
"order_by": 16,
"order_by": 32,
"metric": "Listings Booked in Month",
"value": "listings_booked_in_month",
"previous_year_value": "previous_year_listings_booked_in_month",
@ -128,7 +128,7 @@
"number_format": "integer",
},
{
"order_by": 17,
"order_by": 33,
"metric": "Listings Booked in 6 Months",
"value": "listings_booked_in_6_months",
"previous_year_value": "previous_year_listings_booked_in_6_months",
@ -136,7 +136,7 @@
"number_format": "integer",
},
{
"order_by": 18,
"order_by": 34,
"metric": "Listings Booked in 12 Months",
"value": "listings_booked_in_12_months",
"previous_year_value": "previous_year_listings_booked_in_12_months",
@ -144,13 +144,21 @@
"number_format": "integer",
},
{
"order_by": 19,
"order_by": 35,
"metric": "Churning Listings",
"value": "churning_listings",
"previous_year_value": "previous_year_churning_listings",
"relative_increment": "relative_increment_churning_listings",
"number_format": "integer",
},
{
"order_by": 40,
"metric": "Host Resolutions Payment Count",
"value": "xero_host_resolution_payment_count",
"previous_year_value": "previous_year_xero_host_resolution_payment_count",
"relative_increment": "relative_increment_xero_host_resolution_payment_count",
"number_format": "integer",
},
{
"order_by": 100,
"metric": "Guest Journey Start Rate",
@ -185,30 +193,62 @@
},
{
"order_by": 200,
"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",
"metric": "Total Revenue",
"value": "total_revenue_in_gbp",
"previous_year_value": "previous_year_total_revenue_in_gbp",
"relative_increment": "relative_increment_total_revenue_in_gbp",
"number_format": "currency_gbp",
},
{
{
"order_by": 201,
"metric": "Guest Payments per Guest Journey Completed",
"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",
"metric": "Total Revenue per Booking Created",
"value": "total_revenue_per_created_booking",
"previous_year_value": "previous_year_total_revenue_per_created_booking",
"relative_increment": "relative_increment_total_revenue_per_created_booking",
"number_format": "currency_gbp",
},
{
"order_by": 202,
"metric": "Guest Payments per Guest Journey with Payment",
"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",
"metric": "Total Revenue per Guest Journey Created",
"value": "total_revenue_per_created_guest_journey",
"previous_year_value": "previous_year_total_revenue_per_created_guest_journey",
"relative_increment": "relative_increment_total_revenue_per_created_guest_journey",
"number_format": "currency_gbp",
},
{
"order_by": 203,
"metric": "Total Revenue per Deals Booked in Month",
"value": "total_revenue_per_deals_booked_in_month",
"previous_year_value": "previous_year_total_revenue_per_deals_booked_in_month",
"relative_increment": "relative_increment_total_revenue_per_deals_booked_in_month",
"number_format": "currency_gbp",
},
{
"order_by": 204,
"metric": "Total Revenue per Listings Booked in Month",
"value": "total_revenue_per_listings_booked_in_month",
"previous_year_value": "previous_year_total_revenue_per_listings_booked_in_month",
"relative_increment": "relative_increment_total_revenue_per_listings_booked_in_month",
"number_format": "currency_gbp",
},
{
"order_by": 220,
"metric": "Invoiced Operator Revenue",
"value": "xero_operator_net_fees_in_gbp",
"previous_year_value": "previous_year_xero_operator_net_fees_in_gbp",
"relative_increment": "relative_increment_xero_operator_net_fees_in_gbp",
"number_format": "currency_gbp",
},
{
"order_by": 230,
"metric": "Invoiced APIs Revenue",
"value": "xero_apis_net_fees_in_gbp",
"previous_year_value": "previous_year_xero_apis_net_fees_in_gbp",
"relative_increment": "relative_increment_xero_apis_net_fees_in_gbp",
"number_format": "currency_gbp",
},
{
"order_by": 250,
"metric": "Guest Revenue",
"value": "total_guest_revenue_in_gbp",
"previous_year_value": "previous_year_total_guest_revenue_in_gbp",
@ -216,7 +256,7 @@
"number_format": "currency_gbp",
},
{
"order_by": 204,
"order_by": 251,
"metric": "Guest Revenue per Guest Journey Completed",
"value": "guest_revenue_per_completed_guest_journey",
"previous_year_value": "previous_year_guest_revenue_per_completed_guest_journey",
@ -224,12 +264,44 @@
"number_format": "currency_gbp",
},
{
"order_by": 205,
"order_by": 252,
"metric": "Guest Revenue per Guest Journey with Payment",
"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",
},
{
"order_by": 270,
"metric": "Host Resolutions Amount Paid",
"value": "xero_host_resolution_amount_paid_in_gbp",
"previous_year_value": "previous_year_xero_host_resolution_amount_paid_in_gbp",
"relative_increment": "relative_increment_xero_host_resolution_amount_paid_in_gbp",
"number_format": "currency_gbp",
},
{
"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",
"number_format": "currency_gbp",
},
{
"order_by": 291,
"metric": "Guest Payments per Guest Journey Completed",
"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": 292,
"metric": "Guest Payments per Guest Journey with Payment",
"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",
}
] %}
with

View file

@ -96,9 +96,12 @@ with
guest_revenue.total_guest_revenue_in_gbp,
-- TOTAL REVENUE --
guest_revenue.total_guest_revenue_in_gbp
+ invoicing.xero_operator_net_fees_in_gbp
+ invoicing.xero_apis_net_fees_in_gbp as total_revenue_in_gbp,
nullif(
coalesce(guest_revenue.total_guest_revenue_in_gbp, 0)
+ coalesce(invoicing.xero_operator_net_fees_in_gbp, 0)
+ coalesce(invoicing.xero_apis_net_fees_in_gbp, 0),
0
) as total_revenue_in_gbp,
-- GUEST REVENUE AND PAYMENTS WEIGHTED METRICS --
guest_revenue.total_guest_payments_in_gbp / nullif(
@ -116,29 +119,29 @@ with
-- TOTAL REVENUE WEIGHTED METRICS --
(
guest_revenue.total_guest_revenue_in_gbp
+ invoicing.xero_operator_net_fees_in_gbp
+ invoicing.xero_apis_net_fees_in_gbp
coalesce(guest_revenue.total_guest_revenue_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,
(
guest_revenue.total_guest_revenue_in_gbp
+ invoicing.xero_operator_net_fees_in_gbp
+ invoicing.xero_apis_net_fees_in_gbp
coalesce(guest_revenue.total_guest_revenue_in_gbp, 0)
+ coalesce(invoicing.xero_operator_net_fees_in_gbp, 0)
+ coalesce(invoicing.xero_apis_net_fees_in_gbp, 0)
) / nullif(
guest_journeys.created_guest_journeys, 0
) as total_revenue_per_created_guest_journey,
(
guest_revenue.total_guest_revenue_in_gbp
+ invoicing.xero_operator_net_fees_in_gbp
+ invoicing.xero_apis_net_fees_in_gbp
coalesce(guest_revenue.total_guest_revenue_in_gbp, 0)
+ coalesce(invoicing.xero_operator_net_fees_in_gbp, 0)
+ coalesce(invoicing.xero_apis_net_fees_in_gbp, 0)
) / nullif(
deals.deals_booked_in_month, 0
) as total_revenue_per_deals_booked_in_month,
(
guest_revenue.total_guest_revenue_in_gbp
+ invoicing.xero_operator_net_fees_in_gbp
+ invoicing.xero_apis_net_fees_in_gbp
coalesce(guest_revenue.total_guest_revenue_in_gbp, 0)
+ coalesce(invoicing.xero_operator_net_fees_in_gbp, 0)
+ coalesce(invoicing.xero_apis_net_fees_in_gbp, 0)
) / nullif(
accommodations.listings_booked_in_month, 0
) as total_revenue_per_listings_booked_in_month