Merged PR 4483: Adding targets (to be revised). Allows multi-year last-date computation
# Description Changes: * Adds template for targets -> These need to be revised * Adds comparison of values vs. targets * Allows for multi-year last date computation (allowing multiple years to be selected, not just the last one) # 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: #27609, #27805
This commit is contained in:
parent
cbed87404e
commit
85c2c73da7
6 changed files with 332 additions and 40 deletions
|
|
@ -2073,3 +2073,61 @@ models:
|
|||
data_type: numeric
|
||||
description: |
|
||||
Relative difference between the current year YTD and the previous year YTD.
|
||||
|
||||
- name: target_eom_value
|
||||
data_type: numeric
|
||||
description: |
|
||||
The EOM target value for this metric. This is the value that we aim to
|
||||
achieve by the end of the month. It can be null if the target is not
|
||||
available.
|
||||
|
||||
- name: target_ytd_value
|
||||
data_type: numeric
|
||||
description: |
|
||||
The YTD target value for this metric. This is the cumulative value that we
|
||||
aim to achieve by the end of each month with respect to the beginning of the
|
||||
financial year, that will put us to reach the EOFY target. It can be null if
|
||||
the target is not available.
|
||||
|
||||
- name: target_eofy_value
|
||||
data_type: numeric
|
||||
description: |
|
||||
The EOFY target value for this metric. This is the value that we aim to
|
||||
achieve by the end of the financial year. It can be null if the target is
|
||||
not available.
|
||||
|
||||
- name: diff_current_month_mtd_vs_eom_target
|
||||
data_type: numeric
|
||||
description: |
|
||||
Difference between the current month MTD and the EOM target. It can be null
|
||||
if the target is not available.
|
||||
|
||||
- name: diff_current_ytd_vs_ytd_target
|
||||
data_type: numeric
|
||||
description: |
|
||||
Difference between the current year YTD and the YTD target. It can be null
|
||||
if the target is not available.
|
||||
|
||||
- name: diff_current_ytd_vs_eofy_target
|
||||
data_type: numeric
|
||||
description: |
|
||||
Difference between the current year YTD and the EOFY target. It can be null
|
||||
if the target is not available.
|
||||
|
||||
- name: rel_diff_current_month_mtd_vs_eom_target
|
||||
data_type: numeric
|
||||
description: |
|
||||
Relative difference between the current month MTD and the EOM target. It can be null
|
||||
if the target is not available.
|
||||
|
||||
- name: rel_diff_current_ytd_vs_ytd_target
|
||||
data_type: numeric
|
||||
description: |
|
||||
Relative difference between the current year YTD and the YTD target. It can be null
|
||||
if the target is not available.
|
||||
|
||||
- name: achievement_rate_current_ytd_vs_eofy_target
|
||||
data_type: numeric
|
||||
description: |
|
||||
Achievement rate between the current year YTD and the EOFY target. It can be null
|
||||
if the target is not available.
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ with
|
|||
int_ytd_mtd_aggregated_main_metrics_overview as (
|
||||
select * from {{ ref("int_ytd_mtd_aggregated_main_metrics_overview") }}
|
||||
),
|
||||
latest_dates as (
|
||||
select dimension, id_metric, max(date) as latest_available_date
|
||||
latest_dates_per_financial_year as (
|
||||
select dimension, financial_year, id_metric, max(date) as latest_available_date
|
||||
from int_ytd_mtd_aggregated_main_metrics_overview
|
||||
where
|
||||
(
|
||||
|
|
@ -19,7 +19,7 @@ with
|
|||
or requires_invoicing_data = false
|
||||
)
|
||||
-- To do: handle exclusion for Churn/MRR metrics once these are created
|
||||
group by dimension, id_metric
|
||||
group by dimension, financial_year, id_metric
|
||||
)
|
||||
select
|
||||
m.calendar_year as calendar_year,
|
||||
|
|
@ -46,10 +46,22 @@ select
|
|||
as rel_diff_current_month_mtd_vs_previous_month_eom,
|
||||
m.rel_diff_current_month_mtd_vs_previous_year_mtd
|
||||
as rel_diff_current_month_mtd_vs_previous_year_mtd,
|
||||
m.rel_diff_current_ytd_vs_previous_ytd as rel_diff_current_ytd_vs_previous_ytd
|
||||
m.rel_diff_current_ytd_vs_previous_ytd as rel_diff_current_ytd_vs_previous_ytd,
|
||||
m.target_eom_value as target_eom_value,
|
||||
m.diff_current_month_mtd_vs_eom_target as diff_current_month_mtd_vs_eom_target,
|
||||
m.rel_diff_current_month_mtd_vs_eom_target
|
||||
as rel_diff_current_month_mtd_vs_eom_target,
|
||||
m.target_ytd_value as target_ytd_value,
|
||||
m.diff_current_ytd_vs_ytd_target as diff_current_ytd_vs_ytd_target,
|
||||
m.rel_diff_current_ytd_vs_ytd_target as rel_diff_current_ytd_vs_ytd_target,
|
||||
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
|
||||
from int_ytd_mtd_aggregated_main_metrics_overview m
|
||||
inner join
|
||||
latest_dates ld
|
||||
latest_dates_per_financial_year ld
|
||||
on m.dimension = ld.dimension
|
||||
and m.id_metric = ld.id_metric
|
||||
and m.financial_year = ld.financial_year
|
||||
and m.date <= ld.latest_available_date
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue