data-dwh-dbt-project/models/intermediate/kpis
Oriol Roqué Paniagua fa6114b2af Merged PR 4970: Fix data quality issue on Revenue Retained metrics
# Description

As raised by Kayla, Retained metrics are not computed correctly in AM Account Margin report, see screenshot:

![image.png](https://guardhog.visualstudio.com/4148d95f-4b6d-4205-bcff-e9c8e0d2ca65/_apis/git/repositories/54ac356f-aad7-46d2-b62c-e8c5b3bb8ebf/pullRequests/4970/attachments/image.png)

Issue lies in the fact that Guest Payments contains more dimensions than the rest of the models. This is generating duplicates in the combination_of_sources CTE, but these are effectively hidden because of the sum() applied of the metrics.

In the case of a Deal having in the same day Guest Payments with different dimensions from those selected, AND on the same day having a value on Invoiced Revenue or Host Resolutions, then the Invoiced Revenue or Host Resolutions would be duplicated.

This PR aims to fix this issue, and also adds a few tests on the base model for AM Account Margin to ensure this is kind of error raises an alert.

I'll be debugging other affected models and increase the robustness test-wise; as well as gathering the full impact.

# 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.
- [ ] I have checked for DRY opportunities with other models and docs.
- [ ] 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: #29227
2025-04-10 07:23:31 +00:00
..
projected Merged PR 4665: Projected Bookings to the end of the current month 2025-03-11 14:34:30 +00:00
_kpis_readme.md Merged PR 3329: First version of KPIs refactored - created bookings 2024-10-30 08:55:19 +00:00
int_kpis__agg_daily_created_bookings.sql Merged PR 4665: Projected Bookings to the end of the current month 2025-03-11 14:34:30 +00:00
int_kpis__agg_daily_deals.sql Merged PR 4395: Propagates business scope into Deal/Listing metrics 2025-02-13 16:34:14 +00:00
int_kpis__agg_daily_listings.sql Merged PR 3461: Creates models for listing metrics 2024-11-07 16:56:43 +00:00
int_kpis__agg_daily_new_dash_accommodation_offered_services.sql removed macro and kept all logic inside the model 2025-04-02 12:05:01 +02:00
int_kpis__agg_daily_new_dash_chargeable_services.sql removed macro and kept all logic inside the model 2025-04-02 12:05:01 +02:00
int_kpis__agg_daily_new_dash_created_bookings.sql removed macro and kept all logic inside the model 2025-04-02 12:05:01 +02:00
int_kpis__agg_daily_new_dash_created_services.sql removed macro and kept all logic inside the model 2025-04-02 12:05:01 +02:00
int_kpis__agg_daily_new_dash_deals_offered_services.sql Addressed comments 2025-03-27 12:31:52 +01:00
int_kpis__agg_dates_main_kpis.sql Merged PR 4411: Propagates New Dash/Old Dash/APIs split in KPIs as per Business Scope 2025-02-14 14:12:39 +00:00
int_kpis__agg_monthly_billable_bookings.sql aggregated to agg 2024-11-05 12:17:26 +01:00
int_kpis__agg_monthly_check_out_bookings.sql Merged PR 4425: Reworks Billable Bookings metrics 2025-02-17 15:59:21 +00:00
int_kpis__agg_monthly_churn_contribution.sql Merged PR 4926: KPIs Refactor Stage 3 - Creates dedicated Churn model in KPIs 2025-04-04 14:02:32 +00:00
int_kpis__agg_monthly_completed_guest_journeys.sql aggregated to agg 2024-11-05 12:17:26 +01:00
int_kpis__agg_monthly_created_bookings.sql Merged PR 4304: Adds Cancelled and Not Cancelled Created Bookings 2025-02-06 13:13:02 +00:00
int_kpis__agg_monthly_created_guest_journeys.sql aggregated to agg 2024-11-05 12:17:26 +01:00
int_kpis__agg_monthly_guest_journeys_with_payment.sql aggregated to agg 2024-11-05 12:17:26 +01:00
int_kpis__agg_monthly_guest_payments.sql renamed test entity 2024-11-07 12:56:49 +01:00
int_kpis__agg_monthly_host_resolutions.sql Merged PR 3419: Adds Host Resolutions metrics in new KPIs 2024-11-05 07:45:41 +00:00
int_kpis__agg_monthly_invoiced_revenue.sql Merged PR 4757: Creates a Total Booking Fees metric (Old dash + New dash) 2025-03-20 13:45:44 +00:00
int_kpis__agg_monthly_new_dash_accommodation_offered_services.sql removed macro and kept all logic inside the model 2025-04-02 12:05:01 +02:00
int_kpis__agg_monthly_new_dash_chargeable_services.sql removed macro and kept all logic inside the model 2025-04-02 12:05:01 +02:00
int_kpis__agg_monthly_new_dash_created_bookings.sql Update to listing count in new dash overview 2025-04-03 16:00:43 +02:00
int_kpis__agg_monthly_new_dash_created_services.sql removed macro and kept all logic inside the model 2025-04-02 12:05:01 +02:00
int_kpis__agg_monthly_new_dash_deals_offered_services.sql Addressed comments 2025-03-27 12:31:52 +01:00
int_kpis__agg_monthly_onboarding_mrr.sql Merged PR 4935: KPIs Refactor Stage 4 - Onboarding MRR model in KPIs 2025-04-07 12:27:28 +00:00
int_kpis__agg_monthly_started_guest_journeys.sql aggregated to agg 2024-11-05 12:17:26 +01:00
int_kpis__agg_monthly_total_and_retained_revenue.sql Adds Monthly/MTD and Aggregated/Metric models for Total and Retained Revenue 2025-04-01 17:41:56 +02:00
int_kpis__agg_mtd_billable_bookings.sql aggregated to agg 2024-11-05 12:17:26 +01:00
int_kpis__agg_mtd_check_out_bookings.sql Merged PR 4425: Reworks Billable Bookings metrics 2025-02-17 15:59:21 +00:00
int_kpis__agg_mtd_completed_guest_journeys.sql aggregated to agg 2024-11-05 12:17:26 +01:00
int_kpis__agg_mtd_created_bookings.sql Merged PR 4304: Adds Cancelled and Not Cancelled Created Bookings 2025-02-06 13:13:02 +00:00
int_kpis__agg_mtd_created_guest_journeys.sql aggregated to agg 2024-11-05 12:17:26 +01:00
int_kpis__agg_mtd_guest_journeys_with_payment.sql aggregated to agg 2024-11-05 12:17:26 +01:00
int_kpis__agg_mtd_guest_payments.sql renamed test entity 2024-11-07 12:56:49 +01:00
int_kpis__agg_mtd_host_resolutions.sql Merged PR 3419: Adds Host Resolutions metrics in new KPIs 2024-11-05 07:45:41 +00:00
int_kpis__agg_mtd_invoiced_revenue.sql Merged PR 4757: Creates a Total Booking Fees metric (Old dash + New dash) 2025-03-20 13:45:44 +00:00
int_kpis__agg_mtd_started_guest_journeys.sql aggregated to agg 2024-11-05 12:17:26 +01:00
int_kpis__agg_mtd_total_and_retained_revenue.sql Adds Monthly/MTD and Aggregated/Metric models for Total and Retained Revenue 2025-04-01 17:41:56 +02:00
int_kpis__agg_weekly_new_dash_accommodation_offered_services.sql removed macro and kept all logic inside the model 2025-04-02 12:05:01 +02:00
int_kpis__agg_weekly_new_dash_chargeable_services.sql removed macro and kept all logic inside the model 2025-04-02 12:05:01 +02:00
int_kpis__agg_weekly_new_dash_created_bookings.sql Fixed weekly model 2025-04-03 17:44:09 +02:00
int_kpis__agg_weekly_new_dash_created_services.sql removed macro and kept all logic inside the model 2025-04-02 12:05:01 +02:00
int_kpis__agg_weekly_new_dash_deals_offered_services.sql Addressed comments 2025-03-27 12:31:52 +01:00
int_kpis__dimension_daily_accommodation.sql Merged PR 3329: First version of KPIs refactored - created bookings 2024-10-30 08:55:19 +00:00
int_kpis__dimension_date_product_guest.sql Merged PR 4124: Adds dedicated start date for KPIs 2025-01-21 11:18:16 +00:00
int_kpis__dimension_dates.sql Merged PR 4124: Adds dedicated start date for KPIs 2025-01-21 11:18:16 +00:00
int_kpis__dimension_deals.sql Addressed comments 2025-03-14 14:20:57 +01:00
int_kpis__lifecycle_daily_accommodation.sql Merged PR 3433: Change lifecycle daily to just handle last available day 2024-11-06 11:10:31 +00:00
int_kpis__lifecycle_daily_deal.sql Added boolean 2025-03-28 09:02:12 +01:00
int_kpis__metric_daily_billable_bookings.sql Merged PR 4425: Reworks Billable Bookings metrics 2025-02-17 15:59:21 +00:00
int_kpis__metric_daily_check_in_attributed_guest_journeys.sql Changed to updated_at_utc 2024-11-19 09:23:28 +01:00
int_kpis__metric_daily_check_out_bookings.sql Merged PR 4425: Reworks Billable Bookings metrics 2025-02-17 15:59:21 +00:00
int_kpis__metric_daily_completed_guest_journeys.sql Merged PR 4374: Ensures KYG lite users are excluded from New and Old Dash 2025-02-13 09:38:43 +00:00
int_kpis__metric_daily_created_bookings.sql Merged PR 4374: Ensures KYG lite users are excluded from New and Old Dash 2025-02-13 09:38:43 +00:00
int_kpis__metric_daily_created_guest_journeys.sql Merged PR 4374: Ensures KYG lite users are excluded from New and Old Dash 2025-02-13 09:38:43 +00:00
int_kpis__metric_daily_deals.sql Merged PR 4395: Propagates business scope into Deal/Listing metrics 2025-02-13 16:34:14 +00:00
int_kpis__metric_daily_guest_journeys_with_payment.sql Merged PR 4374: Ensures KYG lite users are excluded from New and Old Dash 2025-02-13 09:38:43 +00:00
int_kpis__metric_daily_guest_payments.sql Merged PR 4374: Ensures KYG lite users are excluded from New and Old Dash 2025-02-13 09:38:43 +00:00
int_kpis__metric_daily_host_resolutions.sql Merged PR 4349: Xero metrics by Business Scope 2025-02-11 15:13:42 +00:00
int_kpis__metric_daily_invoiced_revenue.sql Merged PR 4757: Creates a Total Booking Fees metric (Old dash + New dash) 2025-03-20 13:45:44 +00:00
int_kpis__metric_daily_listings.sql Merged PR 4413: Fixes on Business Scope 2025-02-14 16:17:41 +00:00
int_kpis__metric_daily_new_dash_accommodation_offered_services.sql Addressed comments 2025-03-27 11:24:17 +01:00
int_kpis__metric_daily_new_dash_chargeable_services.sql Updated all PK in created and chargeable services models 2024-12-02 12:42:47 +01:00
int_kpis__metric_daily_new_dash_created_bookings.sql Addressed comments 2025-04-02 12:04:26 +02:00
int_kpis__metric_daily_new_dash_created_services.sql Updated all PK in created and chargeable services models 2024-12-02 12:42:47 +01:00
int_kpis__metric_daily_new_dash_deals_offered_services.sql Commit wip 2025-03-25 17:11:02 +01:00
int_kpis__metric_daily_started_guest_journeys.sql Merged PR 4374: Ensures KYG lite users are excluded from New and Old Dash 2025-02-13 09:38:43 +00:00
int_kpis__metric_daily_total_and_retained_revenue.sql Merged PR 4970: Fix data quality issue on Revenue Retained metrics 2025-04-10 07:23:31 +00:00
int_kpis__metric_monthly_billable_bookings.sql Merged PR 4400: Adds Billable Bookings split per scope 2025-02-14 12:29:18 +00:00
int_kpis__metric_monthly_check_out_bookings.sql Merged PR 4425: Reworks Billable Bookings metrics 2025-02-17 15:59:21 +00:00
int_kpis__metric_monthly_completed_guest_journeys.sql Merged PR 4352: Bulk update dash_source to business_scope 2025-02-11 16:19:33 +00:00
int_kpis__metric_monthly_created_bookings.sql Merged PR 4352: Bulk update dash_source to business_scope 2025-02-11 16:19:33 +00:00
int_kpis__metric_monthly_created_guest_journeys.sql Merged PR 4352: Bulk update dash_source to business_scope 2025-02-11 16:19:33 +00:00
int_kpis__metric_monthly_guest_journeys_with_payment.sql Merged PR 4352: Bulk update dash_source to business_scope 2025-02-11 16:19:33 +00:00
int_kpis__metric_monthly_guest_payments.sql Merged PR 4352: Bulk update dash_source to business_scope 2025-02-11 16:19:33 +00:00
int_kpis__metric_monthly_host_resolutions.sql Merged PR 4357: Propagates in Host Resolutions and Invoiced Revenue the new business scope 2025-02-12 08:17:44 +00:00
int_kpis__metric_monthly_invoiced_revenue.sql Merged PR 4757: Creates a Total Booking Fees metric (Old dash + New dash) 2025-03-20 13:45:44 +00:00
int_kpis__metric_monthly_new_dash_chargeable_services.sql Updated all PK in created and chargeable services models 2024-12-02 12:42:47 +01:00
int_kpis__metric_monthly_new_dash_created_services.sql Updated all PK in created and chargeable services models 2024-12-02 12:42:47 +01:00
int_kpis__metric_monthly_started_guest_journeys.sql Merged PR 4352: Bulk update dash_source to business_scope 2025-02-11 16:19:33 +00:00
int_kpis__metric_monthly_total_and_retained_revenue.sql Adds Monthly/MTD and Aggregated/Metric models for Total and Retained Revenue 2025-04-01 17:41:56 +02:00
int_kpis__metric_mtd_billable_bookings.sql Merged PR 4400: Adds Billable Bookings split per scope 2025-02-14 12:29:18 +00:00
int_kpis__metric_mtd_check_out_bookings.sql Merged PR 4425: Reworks Billable Bookings metrics 2025-02-17 15:59:21 +00:00
int_kpis__metric_mtd_completed_guest_journeys.sql Merged PR 4352: Bulk update dash_source to business_scope 2025-02-11 16:19:33 +00:00
int_kpis__metric_mtd_created_bookings.sql Merged PR 4352: Bulk update dash_source to business_scope 2025-02-11 16:19:33 +00:00
int_kpis__metric_mtd_created_guest_journeys.sql Merged PR 4352: Bulk update dash_source to business_scope 2025-02-11 16:19:33 +00:00
int_kpis__metric_mtd_guest_journeys_with_payment.sql Merged PR 4352: Bulk update dash_source to business_scope 2025-02-11 16:19:33 +00:00
int_kpis__metric_mtd_guest_payments.sql Merged PR 4352: Bulk update dash_source to business_scope 2025-02-11 16:19:33 +00:00
int_kpis__metric_mtd_host_resolutions.sql Merged PR 4357: Propagates in Host Resolutions and Invoiced Revenue the new business scope 2025-02-12 08:17:44 +00:00
int_kpis__metric_mtd_invoiced_revenue.sql Merged PR 4757: Creates a Total Booking Fees metric (Old dash + New dash) 2025-03-20 13:45:44 +00:00
int_kpis__metric_mtd_started_guest_journeys.sql Merged PR 4352: Bulk update dash_source to business_scope 2025-02-11 16:19:33 +00:00
int_kpis__metric_mtd_total_and_retained_revenue.sql Adds Monthly/MTD and Aggregated/Metric models for Total and Retained Revenue 2025-04-01 17:41:56 +02:00
int_kpis__metric_weekly_new_dash_chargeable_services.sql Updated all PK in created and chargeable services models 2024-12-02 12:42:47 +01:00
int_kpis__metric_weekly_new_dash_created_services.sql Updated all PK in created and chargeable services models 2024-12-02 12:42:47 +01:00
int_kpis__product_guest_agg_metrics.sql modify ugly name 2025-03-20 17:03:13 +01:00
int_kpis__product_guest_daily_metrics.sql fixed model copy paste 2024-11-26 12:36:54 +01:00
int_kpis__product_new_dash_agg_metrics.sql Changed loop 2025-04-02 12:55:04 +02:00
schema.yml Merged PR 4935: KPIs Refactor Stage 4 - Onboarding MRR model in KPIs 2025-04-07 12:27:28 +00:00