Merged PR 4948: Reporting model for mtd aggregated metrics by deal

# Description

Creates a new model for reporting. It includes any relevant metric at Deal level in a similar format as we do for `mtd_aggregated_metrics`. Additionally, there's few Deal attributes - from Hubspot, segmentations, lifecycles, etc.

In order to dynamically choose which metrics are relevant on a Deal level, I modified the configuration in `int_mtd_aggregated_metrics` so the extraction is under control.

# 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.
- [X] I have checked for DRY opportunities with other models and docs.
- [X] I've picked the right materialization for the affected models. **Worth discussing the possibilities to include indexes in the future**

# Other

- [ ] Check if a full-refresh is required after this PR is merged.

Related work items: #28998
This commit is contained in:
Oriol Roqué Paniagua 2025-04-08 10:04:11 +00:00
parent ca5db795a3
commit a67e3f46ba
5 changed files with 558 additions and 1 deletions

View file

@ -283,6 +283,14 @@ models:
order for displaying purposes. Null values are accepted, but keep
in mind that then there's no default controlled display order.
- name: include_in_account_reporting
data_type: boolean
description: |
Category to indicate if the metric should be included in the account
reporting (by deal). This will limit the display for reporting purposes.
data_tests:
- not_null
- name: display_exclusion
data_type: string
description: |
@ -2602,3 +2610,154 @@ models:
Relative difference between the current year YTD and the YTD target,
with a sign to represent if the relative difference is good (positive) or bad
(negative) for our business.
- name: int_mtd_aggregated_metrics_by_deal
description: |
This model aggregates the historic information of our business by providing
different metrics at account level (by id_deal).
Additionally it provides Deal attributes.
data_tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- date
- metric
- id_deal
columns:
- name: year
data_type: int
description: Year number of the given date.
- name: month
data_type: int
description: Month number of the given date.
- name: day
data_type: int
description: Day monthly number of the given date.
- name: is_end_of_month
data_type: boolean
description: Is end of month, 1 for yes, 0 for no.
- name: is_current_month
data_type: boolean
description: |
Checks if the date is within the current executed month,
1 for yes, 0 for no.
- name: is_end_of_month_or_yesterday
data_type: boolean
description: |
Checks if the date is end of month or yesterday,
1 for yes, 0 for no.
- name: first_day_month
data_type: date
description: |
First day of the month corresponding to the date field.
It comes from int_dates_mtd logic.
- name: date
data_type: date
description: |
Main date for the computation, that is used for filters.
It comes from int_dates_mtd logic.
data_tests:
- not_null
- name: id_deal
data_type: string
description: |
Unique ID for a deal, or account.
data_tests:
- not_null
- name: deal
data_type: string
description: |
Combination of the ID and the Name of the deal.
- name: active_accommodations_per_deal_segmentation
data_type: string
description: |
Segment value based on the number of listings booked in 12 months
for a given deal and date.
- name: main_billing_country_iso_3_per_deal
data_type: string
description: |
ISO 3166-1 alpha-3 main country code in which the Deal is billed.
In some cases it's null.
- name: business_scope
data_type: string
description: |
Business scope identifying the metric source.
- name: account_manager
data_type: string
description: |
Account manager of the deal.
In some cases it's null.
- name: deal_lifecycle_state
data_type: string
description: |
Lifecycle state of the deal.
- name: metric
data_type: text
description: Name of the business metric.
data_tests:
- not_null
- name: order_by
data_type: integer
description: |
Order for displaying purposes. Null values are accepted, but keep
in mind that then there's no default controlled display order.
- name: number_format
data_type: text
description: Allows for grouping and formatting for displaying purposes.
- name: value
data_type: numeric
description: |
Numeric value (integer or decimal) that corresponds to the MTD computation of the metric
at a given date. Note that if the month is not in progress, then this value corresponds
to the monthly figure.
- name: previous_year_value
data_type: numeric
description: |
Numeric value (integer or decimal) that corresponds to the MTD computation of the metric
on the previous year at a given date.
- name: relative_increment
data_type: numeric
description: |
Numeric value that corresponds to the relative increment between value and previous year value,
following the computation: value / previous_year_value - 1.
- name: relative_increment_with_sign_format
data_type: numeric
description: |
Relative_increment value multiplied by -1 in case this metric's growth doesn't have a
positive impact for Truvi, otherwise is equal to relative_increment.
This value is specially created for formatting in PBI
- name: display_exclusion
data_type: string
description: |
Category to indicate if the metric requires a certain exclusion due
to relying on not timely information.
This will limit the display for reporting purposes.
data_tests:
- not_null
- accepted_values:
values:
- NONE
- INVOICING
- ONGOING_MONTH