Merged PR 2003: Business KPIs first draft

This PR aims to provide a first draft for business KPIs, at this stage **quite minimal**.

It mostly contains a MTD and Monthly display approach. No dimensions are created.

The models created are:
- **int_dates_mtd**: mainly it reads from int_dates to retrieve those days needed for a MTD/monthly display
- **int_core__mtd_booking_metrics**: it contains the booking metrics, ending in a format of date|value|value last year|increment
--> here we could add, in the future, additional metrics from other sources (ex: guest journey, etc)
- **int_core__mtd_aggregated_metrics**: it transforms the data coming from the different mtd intermediate sources to be easily displayed in the dashboard. This is a good candidate for macros :)
- **core__mtd_aggregated_metrics**: copy-paste of the its int_core version, including a bit of model documentation

The dashboard is functional but in another PR. I can show you how it looks like at the moment you are going to check the PR

Related work items: #17214
This commit is contained in:
Oriol Roqué Paniagua 2024-06-11 15:45:57 +00:00
parent 366aa7d1ac
commit 328723b9ab
7 changed files with 482 additions and 1 deletions

View file

@ -0,0 +1,19 @@
with
int_core__mtd_aggregated_metrics as (
select * from {{ ref("int_core__mtd_aggregated_metrics") }}
)
select
year as year,
month as month,
day as day,
is_end_of_month as is_end_of_month,
is_current_month as is_current_month,
date as date,
previous_year_date as previous_year_date,
order_by as order_by,
metric as metric,
value as value,
previous_year_value as previous_year_value,
relative_increment as relative_increment
from int_core__mtd_aggregated_metrics

View file

@ -564,4 +564,92 @@ models:
- name: dwh_extracted_at_utc
data_type: timestamp with time zone
description: ""
description: ""
- name: core__mtd_aggregated_metrics
description: |
This is a month-to-date aggregated table designed to support
the business KPIs reporting.
At this stage, it's mostly a draft.
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- date
- metric
columns:
- 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: is_end_of_month
data_type: boolean
description: is end of month, 1 for yes, 0 for no.
tests:
- not_null
- name: is_current_month
data_type: boolean
description: |
checks if the date is within the current executed month,
1 for yes, 0 for no.
tests:
- not_null
- name: date
data_type: date
description: |
main date for the computation, that is used for filters.
It comes from int_dates_mtd logic.
tests:
- not_null
- 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.
- name: metric
data_type: text
description: name of the business metric.
tests:
- not_null
- name: value
data_type: int8
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.
- 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.
- 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.