data-dwh-dbt-project/models/intermediate
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
..
athena Update athena models to remove id_accommodation 2025-02-24 15:21:44 +01:00
check_in_hero adding id_deal to api models 2025-03-19 09:23:23 +01:00
core upgraded screening 2025-04-08 12:09:08 +02:00
cross Merged PR 4970: Fix data quality issue on Revenue Retained metrics 2025-04-10 07:23:31 +00:00
edeposit Addressed comments 2025-03-19 12:06:05 +01:00
hubspot Merged PR 4918: Adds Integration Type from Hubspot Deals 2025-04-04 08:40:38 +00:00
kpis Merged PR 4970: Fix data quality issue on Revenue Retained metrics 2025-04-10 07:23:31 +00:00
resolutions Calculator changes 2025-02-28 12:19:24 +01:00
screen_and_protect adding id_deal to api models 2025-03-19 09:23:23 +01:00
xero Merged PR 4734: Bugfix - Ensures accounts cannot be duplicated in Xero sales monthly trends 2025-03-19 08:19:20 +00:00