Merged PR 2179: Computes aggregated metrics by deal id and exposes it to reporting

This PR creates 2 new models:
- `int_core__monthly_aggregated_metrics_history_by_deal`, which just gathers the information of the previously created models that compute the kpis by deal id.
- `core__monthly_aggregated_metrics_history_by_deal`, effectively a copy from intermediate to reporting

It also includes documentation of these 2 models, differences between these and the `mtd_aggregated_metrics` equivalents and references it to exposures. I took the opportunity to update the documentation of the `core__mtd_aggregated_metrics` now that it's a bit more mature.

This should be the last PR for the first draft of 'by deal' metrics.

Related work items: #17689
This commit is contained in:
Oriol Roqué Paniagua 2024-07-03 07:06:34 +00:00
parent f9741d6f69
commit ed5d7828a7
5 changed files with 205 additions and 25 deletions

View file

@ -0,0 +1,28 @@
with
int_core__monthly_aggregated_metrics_history_by_deal as (
select * from {{ ref("int_core__monthly_aggregated_metrics_history_by_deal") }}
)
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
from int_core__monthly_aggregated_metrics_history_by_deal

View file

@ -566,12 +566,14 @@ models:
- name: dwh_extracted_at_utc
data_type: timestamp with time zone
description: ""
- name: core__mtd_aggregated_metrics
description: |
This is a month-to-date aggregated table designed to support
the business KPIs reporting.
This model aggregates the historic information of our business by providing
different metrics computed at global level.
It's the main source of information for the Main KPIs reporting, specifically
on the MTD (Month To Date) and the Monthly Overview.
At this stage, it's mostly a draft.
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
@ -622,13 +624,9 @@ models:
- name: previous_year_date
data_type: date
description: |
equivalent last year date. Mostly unused, just to validate
that the logic works well.
- name: order_by
data_type: int
description: |
an integer used to fix a display order of the metrics in the visuals.
corresponds to the date of the previous year, with respect to the field date.
It comes from int_dates_mtd logic. It's only displayed for information purposes,
should not be needed for reporting.
- name: metric
data_type: text
@ -636,24 +634,91 @@ models:
tests:
- not_null
- name: value
data_type: int8
- name: order_by
data_type: integer
description: |
value of the current metric. It represents the MTD value if the month is
in progress, and the Monthly value if the month has already finished.
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.
tests:
- accepted_values:
values: ['integer', 'percentage']
- 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: int8
description: |
value of the current metric, but from last year. It represents the
last year MTD value if the month is in progress, and the last year
Monthly value if the month has already finished.
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: |
relative increment between value vs. previous_year_value. If previous_year_value is null,
relative_increment will also be null.
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: core__monthly_aggregated_metrics_history_by_deal
description: |
This model aggregates the monthly historic information regarding the different metrics computed
at deal level. The primary sources of data are the `int_core__monthly_XXXXX_history_by_deal`
models which contain the raw metrics data per source.
This table is used to provide "By Deal" metrics in the Business Overview reporting.
Unlike the core__mtd_aggregated_metrics, this model does not abstract each metric, since
no comparison versus last year is performed. In short, it just gathers the information stored
in the abovementioned models.
To keep in mind: aggregating the information of this model will not necessarily result into
the int_core__mtd_aggregated metrics because 1) the mtd version contains more computing dates
than the by deal version, the latest being a subset of the first, and 2) the deal based model
enforces that a booking/guest journey/listing/etc has a host with a deal assigned, which is
not necessarily the case.
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- date
- id_deal
columns:
- name: date
data_type: date
description: The last day of the month or yesterday for historic metrics.
tests:
- not_null
- name: id_deal
data_type: character varying
description: Id of the deal associated to the host.
tests:
- not_null
- name: year
data_type: int
description: year number of the given date.
tests:
- not_null
- name: month
data_type: int
description: month number of the given date.
tests:
- not_null
- name: day
data_type: int
description: day monthly number of the given date.
tests:
- not_null
- name: core__unified_user
description:

View file

@ -99,17 +99,20 @@ exposures:
- name: main_kpis
label: Main Business KPIs
type: dashboard
maturity: medium
maturity: high
url: https://app.powerbi.com/links/ynCnuqVPTr?ctid=862842df-2998-4826-bea9-b726bc01d3a7&pbi_source=linkShare&bookmarkGuid=81e69a3e-90dc-46d7-b313-ba55ca611945
description: |
A PBI report showcasing the main business KPIs of our company.
Includes multiple high-level metrics updated in a daily basis,
ensuring both a Month-to-date comprehension of our business and
a view on historic values on a month-by-month approach
a view on historic values on a month-by-month approach.
Additionally, it allows to retrieve similar KPIs at Deal level.
depends_on:
- ref('core__mtd_aggregated_metrics')
- ref('core__monthly_aggregated_metrics_history_by_deal')
owner:
name: Oriol Roqué