Merged PR 2615: Beautification of KPIs dimensions
# Description Changes: * Separate 1) the internal naming of dimensions available within DWH vs. 2) the display of the dimensions in the reporting. Mainly it changes the "by_number_of_listings" to display "By # of Listings Booked in 12 Months". I edited the production macro since to me it's linked to when things are available for display. * Add preceding zeros on the segmentation so it's ordered correctly. Before, the segment 21-60 was displayed before the 6-20. * Also added some capital letters to the schema config of the reporting model :) I attach a screenshot of how it looks in PBI in my local development branch to exemplify why this is "Beautification". Be aware that merging this also puts in production the dimensions.  # 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. # Other - [ ] Check if a full-refresh is required after this PR is merged. Related work items: #19325
This commit is contained in:
parent
83d913f9fc
commit
85131985d8
5 changed files with 51 additions and 32 deletions
|
|
@ -21,11 +21,14 @@ Macro: get_kpi_dimensions_for_production
|
||||||
Provides the list of Dimensions that will be available in production for the KPIs.
|
Provides the list of Dimensions that will be available in production for the KPIs.
|
||||||
This configuration ensures that working with new dimensions won't affect the display
|
This configuration ensures that working with new dimensions won't affect the display
|
||||||
until all development work has been done.
|
until all development work has been done.
|
||||||
|
Additionally, it provides a proper display name for reporting purposes.
|
||||||
|
|
||||||
To be added: 'by_number_of_listings'
|
{"dimension": "'by_number_of_listings'", "dimension_display": "'By # of Listings Booked in 12 Months'"}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
{% macro get_kpi_dimensions_for_production() %}
|
{% macro get_kpi_dimensions_for_production() %}
|
||||||
{% set dimensions = "('global')" %}
|
{% set dimensions = [
|
||||||
|
{"dimension": "'global'", "dimension_display": "'Global'"}
|
||||||
|
] %}
|
||||||
{{ return(dimensions) }}
|
{{ return(dimensions) }}
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
@ -30,9 +30,9 @@ select
|
||||||
when accommodations_booked_in_12_months = 0
|
when accommodations_booked_in_12_months = 0
|
||||||
then '0'
|
then '0'
|
||||||
when accommodations_booked_in_12_months between 1 and 5
|
when accommodations_booked_in_12_months between 1 and 5
|
||||||
then '1-5'
|
then '01-05'
|
||||||
when accommodations_booked_in_12_months between 6 and 20
|
when accommodations_booked_in_12_months between 6 and 20
|
||||||
then '6-20'
|
then '06-20'
|
||||||
when accommodations_booked_in_12_months between 21 and 60
|
when accommodations_booked_in_12_months between 21 and 60
|
||||||
then '21-60'
|
then '21-60'
|
||||||
when accommodations_booked_in_12_months >= 61
|
when accommodations_booked_in_12_months >= 61
|
||||||
|
|
|
||||||
|
|
@ -1133,8 +1133,8 @@ models:
|
||||||
have been booked within the last 12 months. Thus, it means it only considers the lifecycle states of
|
have been booked within the last 12 months. Thus, it means it only considers the lifecycle states of
|
||||||
03-First Time Booked, 04-Active and 07-Reactivated. The segments are the following:
|
03-First Time Booked, 04-Active and 07-Reactivated. The segments are the following:
|
||||||
- '0'
|
- '0'
|
||||||
- '1-5'
|
- '01-05'
|
||||||
- '6-20'
|
- '06-20'
|
||||||
- '21-60'
|
- '21-60'
|
||||||
- '61+'
|
- '61+'
|
||||||
These segments are inspired from the ones RevOps team uses, but the associated deals and listings volume will differ
|
These segments are inspired from the ones RevOps team uses, but the associated deals and listings volume will differ
|
||||||
|
|
@ -1167,8 +1167,8 @@ models:
|
||||||
- accepted_values:
|
- accepted_values:
|
||||||
values:
|
values:
|
||||||
- '0'
|
- '0'
|
||||||
- '1-5'
|
- '01-05'
|
||||||
- '6-20'
|
- '06-20'
|
||||||
- '21-60'
|
- '21-60'
|
||||||
- '61+'
|
- '61+'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,26 @@
|
||||||
{% set production_dimensions = get_kpi_dimensions_for_production() %}
|
{% set production_dimensions = get_kpi_dimensions_for_production() %}
|
||||||
|
|
||||||
with
|
with
|
||||||
|
dimensions as (
|
||||||
|
{% for dimension in production_dimensions %}
|
||||||
|
select
|
||||||
|
{{ dimension.dimension }} as dimension,
|
||||||
|
{{ dimension.dimension_display }} as dimension_display
|
||||||
|
{% if not loop.last %}
|
||||||
|
union all
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
),
|
||||||
int_mtd_aggregated_metrics as (
|
int_mtd_aggregated_metrics as (
|
||||||
select * from {{ ref("int_mtd_aggregated_metrics") }}
|
select
|
||||||
|
m.*,
|
||||||
|
d.dimension_display
|
||||||
|
from {{ ref("int_mtd_aggregated_metrics") }} m
|
||||||
-- The following clause limits the display execution
|
-- The following clause limits the display execution
|
||||||
-- to only include those dimensions configured to
|
-- to only include those dimensions configured to
|
||||||
-- appear for production purposes
|
-- appear for production purposes
|
||||||
where dimension in ({{ production_dimensions }})
|
inner join dimensions d
|
||||||
|
on m.dimension = d.dimension
|
||||||
)
|
)
|
||||||
|
|
||||||
select
|
select
|
||||||
|
|
@ -17,7 +31,7 @@ select
|
||||||
is_current_month as is_current_month,
|
is_current_month as is_current_month,
|
||||||
first_day_month as first_day_month,
|
first_day_month as first_day_month,
|
||||||
date as date,
|
date as date,
|
||||||
dimension as dimension,
|
dimension_display as dimension,
|
||||||
dimension_value as dimension_value,
|
dimension_value as dimension_value,
|
||||||
previous_year_date as previous_year_date,
|
previous_year_date as previous_year_date,
|
||||||
order_by as order_by,
|
order_by as order_by,
|
||||||
|
|
|
||||||
|
|
@ -317,32 +317,32 @@ models:
|
||||||
columns:
|
columns:
|
||||||
- name: year
|
- name: year
|
||||||
data_type: int
|
data_type: int
|
||||||
description: year number of the given date.
|
description: Year number of the given date.
|
||||||
tests:
|
tests:
|
||||||
- not_null
|
- not_null
|
||||||
|
|
||||||
- name: month
|
- name: month
|
||||||
data_type: int
|
data_type: int
|
||||||
description: month number of the given date.
|
description: Month number of the given date.
|
||||||
tests:
|
tests:
|
||||||
- not_null
|
- not_null
|
||||||
|
|
||||||
- name: day
|
- name: day
|
||||||
data_type: int
|
data_type: int
|
||||||
description: day monthly number of the given date.
|
description: Day monthly number of the given date.
|
||||||
tests:
|
tests:
|
||||||
- not_null
|
- not_null
|
||||||
|
|
||||||
- name: is_end_of_month
|
- name: is_end_of_month
|
||||||
data_type: boolean
|
data_type: boolean
|
||||||
description: is end of month, 1 for yes, 0 for no.
|
description: Is end of month, 1 for yes, 0 for no.
|
||||||
tests:
|
tests:
|
||||||
- not_null
|
- not_null
|
||||||
|
|
||||||
- name: is_current_month
|
- name: is_current_month
|
||||||
data_type: boolean
|
data_type: boolean
|
||||||
description: |
|
description: |
|
||||||
checks if the date is within the current executed month,
|
Checks if the date is within the current executed month,
|
||||||
1 for yes, 0 for no.
|
1 for yes, 0 for no.
|
||||||
tests:
|
tests:
|
||||||
- not_null
|
- not_null
|
||||||
|
|
@ -350,7 +350,7 @@ models:
|
||||||
- name: first_day_month
|
- name: first_day_month
|
||||||
data_type: date
|
data_type: date
|
||||||
description: |
|
description: |
|
||||||
first day of the month correspoding to the date field.
|
First day of the month correspoding to the date field.
|
||||||
It comes from int_dates_mtd logic.
|
It comes from int_dates_mtd logic.
|
||||||
tests:
|
tests:
|
||||||
- not_null
|
- not_null
|
||||||
|
|
@ -358,19 +358,21 @@ models:
|
||||||
- name: date
|
- name: date
|
||||||
data_type: date
|
data_type: date
|
||||||
description: |
|
description: |
|
||||||
main date for the computation, that is used for filters.
|
Main date for the computation, that is used for filters.
|
||||||
It comes from int_dates_mtd logic.
|
It comes from int_dates_mtd logic.
|
||||||
tests:
|
tests:
|
||||||
- not_null
|
- not_null
|
||||||
|
|
||||||
- name: dimension
|
- name: dimension
|
||||||
data_type: string
|
data_type: string
|
||||||
description: The dimension or granularity of the metrics.
|
description: |
|
||||||
|
The dimension or granularity of the metrics. Keep in mind that
|
||||||
|
in this reporting model this field corresponds to the
|
||||||
|
dimension_display; this is, the name of the dimension for
|
||||||
|
displaying purposes.
|
||||||
|
|
||||||
tests:
|
tests:
|
||||||
- accepted_values:
|
- not_null
|
||||||
values:
|
|
||||||
- global
|
|
||||||
- by_number_of_listings
|
|
||||||
|
|
||||||
- name: dimension_value
|
- name: dimension_value
|
||||||
data_type: string
|
data_type: string
|
||||||
|
|
@ -381,25 +383,25 @@ models:
|
||||||
- name: previous_year_date
|
- name: previous_year_date
|
||||||
data_type: date
|
data_type: date
|
||||||
description: |
|
description: |
|
||||||
corresponds to the date of the previous year, with respect to the field date.
|
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,
|
It comes from int_dates_mtd logic. It's only displayed for information purposes,
|
||||||
should not be needed for reporting.
|
should not be needed for reporting.
|
||||||
|
|
||||||
- name: metric
|
- name: metric
|
||||||
data_type: text
|
data_type: text
|
||||||
description: name of the business metric.
|
description: Name of the business metric.
|
||||||
tests:
|
tests:
|
||||||
- not_null
|
- not_null
|
||||||
|
|
||||||
- name: order_by
|
- name: order_by
|
||||||
data_type: integer
|
data_type: integer
|
||||||
description: |
|
description: |
|
||||||
order for displaying purposes. Null values are accepted, but keep
|
Order for displaying purposes. Null values are accepted, but keep
|
||||||
in mind that then there's no default controlled display order.
|
in mind that then there's no default controlled display order.
|
||||||
|
|
||||||
- name: number_format
|
- name: number_format
|
||||||
data_type: text
|
data_type: text
|
||||||
description: allows for grouping and formatting for displaying purposes.
|
description: Allows for grouping and formatting for displaying purposes.
|
||||||
tests:
|
tests:
|
||||||
- accepted_values:
|
- accepted_values:
|
||||||
values: ['integer', 'percentage', 'currency_gbp']
|
values: ['integer', 'percentage', 'currency_gbp']
|
||||||
|
|
@ -407,26 +409,26 @@ models:
|
||||||
- name: value
|
- name: value
|
||||||
data_type: numeric
|
data_type: numeric
|
||||||
description: |
|
description: |
|
||||||
numeric value (integer or decimal) that corresponds to the MTD computation of the metric
|
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
|
at a given date. Note that if the month is not in progress, then this value corresponds
|
||||||
to the monthly figure.
|
to the monthly figure.
|
||||||
|
|
||||||
- name: previous_year_value
|
- name: previous_year_value
|
||||||
data_type: numeric
|
data_type: numeric
|
||||||
description: |
|
description: |
|
||||||
numeric value (integer or decimal) that corresponds to the MTD computation of the metric
|
Numeric value (integer or decimal) that corresponds to the MTD computation of the metric
|
||||||
on the previous year at a given date.
|
on the previous year at a given date.
|
||||||
|
|
||||||
- name: relative_increment
|
- name: relative_increment
|
||||||
data_type: numeric
|
data_type: numeric
|
||||||
description: |
|
description: |
|
||||||
numeric value that corresponds to the relative increment between value and previous year value,
|
Numeric value that corresponds to the relative increment between value and previous year value,
|
||||||
following the computation: value / previous_year_value - 1.
|
following the computation: value / previous_year_value - 1.
|
||||||
|
|
||||||
- name: relative_increment_with_sign_format
|
- name: relative_increment_with_sign_format
|
||||||
data_type: numeric
|
data_type: numeric
|
||||||
description: |
|
description: |
|
||||||
relative_increment value multiplied by -1 in case this metric's growth doesn't have a
|
Relative_increment value multiplied by -1 in case this metric's growth doesn't have a
|
||||||
positive impact for Superhog, otherwise is equal to relative_increment.
|
positive impact for Superhog, otherwise is equal to relative_increment.
|
||||||
This value is specially created for formatting in PBI
|
This value is specially created for formatting in PBI
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue