Relative increments with sign

This commit is contained in:
uri 2025-02-25 12:30:23 +01:00
parent fdec616fe6
commit f5718ded4d
4 changed files with 159 additions and 27 deletions

View file

@ -2131,3 +2131,38 @@ models:
description: |
Achievement rate between the current year YTD and the EOFY target. It can be null
if the target is not available.
- name: rel_diff_with_sign_current_month_mtd_vs_previous_month_eom
data_type: numeric
description: |
Relative difference between the current month MTD and the previous month EOM,
with a sign to represent if the relative difference is good (positive) or bad
(negative) for our business.
- name: rel_diff_with_sign_current_month_mtd_vs_previous_year_mtd
data_type: numeric
description: |
Relative difference between the current month MTD and the previous year MTD,
with a sign to represent if the relative difference is good (positive) or bad
(negative) for our business.
- name: rel_diff_with_sign_current_ytd_vs_previous_ytd
data_type: numeric
description: |
Relative difference between the current year YTD and the previous year YTD,
with a sign to represent if the relative difference is good (positive) or bad
(negative) for our business.
- name: rel_diff_with_sign_current_month_mtd_vs_eom_target
data_type: numeric
description: |
Relative difference between the current month MTD and the EOM target,
with a sign to represent if the relative difference is good (positive) or bad
(negative) for our business.
- name: rel_diff_with_sign_current_ytd_vs_ytd_target
data_type: numeric
description: |
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.

View file

@ -3,7 +3,8 @@ with
select * from {{ ref("int_ytd_mtd_aggregated_main_metrics_overview") }}
),
latest_dates_per_financial_year as (
select dimension, financial_year, id_metric, max(date) as latest_available_date
select
dimension, financial_year, id_metric, max(m.date) as latest_available_date
from int_ytd_mtd_aggregated_main_metrics_overview m
where
(
@ -63,7 +64,17 @@ select
m.target_eofy_value as target_eofy_value,
m.diff_current_ytd_vs_eofy_target as diff_current_ytd_vs_eofy_target,
m.achievement_rate_current_ytd_vs_eofy_target
as achievement_rate_current_ytd_vs_eofy_target
as achievement_rate_current_ytd_vs_eofy_target,
m.rel_diff_with_sign_current_month_mtd_vs_previous_month_eom
as rel_diff_with_sign_current_month_mtd_vs_previous_month_eom,
m.rel_diff_with_sign_current_month_mtd_vs_previous_year_mtd
as rel_diff_with_sign_current_month_mtd_vs_previous_year_mtd,
m.rel_diff_with_sign_current_ytd_vs_previous_ytd
as rel_diff_with_sign_current_ytd_vs_previous_ytd,
m.rel_diff_with_sign_current_month_mtd_vs_eom_target
as rel_diff_with_sign_current_month_mtd_vs_eom_target,
m.rel_diff_with_sign_current_ytd_vs_ytd_target
as rel_diff_with_sign_current_ytd_vs_ytd_target
from int_ytd_mtd_aggregated_main_metrics_overview m
inner join
latest_dates_per_financial_year ld