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
|
|
@ -153,7 +153,11 @@
|
|||
with
|
||||
int_ytd_mtd_main_metrics_overview as (
|
||||
select * from {{ ref("int_ytd_mtd_main_metrics_overview") }}
|
||||
)
|
||||
),
|
||||
stg_seed__main_metrics_targets as (
|
||||
select * from {{ ref("stg_seed__main_metrics_targets") }}
|
||||
),
|
||||
main_metrics_aggregation as (
|
||||
{% for metric in metrics %}
|
||||
select
|
||||
calendar_year,
|
||||
|
|
@ -175,12 +179,15 @@ with
|
|||
- {{ metric.previous_month_EOM }}
|
||||
as diff_current_month_mtd_vs_previous_month_eom,
|
||||
{{ metric.current_month_MTD }}
|
||||
- {{ metric.previous_year_MTD }} as diff_current_month_mtd_vs_previous_year_mtd,
|
||||
- {{ metric.previous_year_MTD }}
|
||||
as diff_current_month_mtd_vs_previous_year_mtd,
|
||||
{{ metric.current_YTD }}
|
||||
- {{ metric.previous_YTD }} as diff_current_ytd_vs_previous_ytd,
|
||||
{{ metric.current_month_MTD }} / nullif({{ metric.previous_month_EOM }}, 0)
|
||||
{{ metric.current_month_MTD }}
|
||||
/ nullif({{ metric.previous_month_EOM }}, 0)
|
||||
- 1 as rel_diff_current_month_mtd_vs_previous_month_eom,
|
||||
{{ metric.current_month_MTD }} / nullif({{ metric.previous_year_MTD }}, 0)
|
||||
{{ metric.current_month_MTD }}
|
||||
/ nullif({{ metric.previous_year_MTD }}, 0)
|
||||
- 1 as rel_diff_current_month_mtd_vs_previous_year_mtd,
|
||||
{{ metric.current_YTD }} / nullif({{ metric.previous_YTD }}, 0)
|
||||
- 1 as rel_diff_current_ytd_vs_previous_ytd
|
||||
|
|
@ -189,3 +196,30 @@ with
|
|||
union all
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
)
|
||||
select
|
||||
metrics.*,
|
||||
-- EOM target --
|
||||
targets.target_eom_value as target_eom_value,
|
||||
metrics.current_month_mtd
|
||||
- targets.target_eom_value as diff_current_month_mtd_vs_eom_target,
|
||||
metrics.current_month_mtd / nullif(targets.target_eom_value, 0)
|
||||
- 1 as rel_diff_current_month_mtd_vs_eom_target,
|
||||
-- YTD target --
|
||||
targets.target_ytd_value as target_ytd_value,
|
||||
metrics.current_year_ytd
|
||||
- targets.target_ytd_value as diff_current_ytd_vs_ytd_target,
|
||||
metrics.current_year_ytd / nullif(targets.target_ytd_value, 0)
|
||||
- 1 as rel_diff_current_ytd_vs_ytd_target,
|
||||
-- EOFY target --
|
||||
targets.target_eofy_value as target_eofy_value,
|
||||
metrics.current_year_ytd
|
||||
- targets.target_eofy_value as diff_current_ytd_vs_eofy_target,
|
||||
metrics.current_year_ytd / nullif(
|
||||
targets.target_eofy_value, 0
|
||||
) as achievement_rate_current_ytd_vs_eofy_target
|
||||
from main_metrics_aggregation as metrics
|
||||
left join
|
||||
stg_seed__main_metrics_targets as targets
|
||||
on metrics.id_metric = targets.id_metric
|
||||
and date_trunc('month', metrics.date) = date_trunc('month', targets.target_date)
|
||||
|
|
|
|||
|
|
@ -2312,3 +2312,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.
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -319,3 +319,57 @@ seeds:
|
|||
- 214-Basic Damage Deposit
|
||||
- 215-Resolution Process for Deposit Management Services
|
||||
- 511-Damage Host-Waiver Payments
|
||||
|
||||
- name: stg_seed__main_metrics_targets
|
||||
description: |
|
||||
A list of financial year targets for the main metrics that we track in the company.
|
||||
data_tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- id_metric
|
||||
- target_date
|
||||
|
||||
columns:
|
||||
- name: id_metric
|
||||
data_type: bigint
|
||||
description: The id of the metric used for joining with other tables.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: metric_name
|
||||
data_type: character varying
|
||||
description: The name of the metric for human consumption
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: target_date
|
||||
data_type: date
|
||||
description: |
|
||||
The date when this target is expected to be achieved.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- 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.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: target_ytd_value
|
||||
data_type: numeric
|
||||
description: |
|
||||
The YTD target value for this metric. This is the cummulative 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.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- 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.
|
||||
data_tests:
|
||||
- not_null
|
||||
|
|
|
|||
76
seeds/stg_seed__main_metrics_targets.csv
Normal file
76
seeds/stg_seed__main_metrics_targets.csv
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
id_metric,metric_name,target_date,target_eom_value,target_ytd_value,target_eofy_value
|
||||
1,Total Revenue,2025-01-31,600000,4510000,5700000
|
||||
1,Total Revenue,2025-02-28,520000,5030000,5700000
|
||||
1,Total Revenue,2025-03-31,670000,5700000,5700000
|
||||
1,Total Revenue,2025-04-30,501094,501094,9000000
|
||||
1,Total Revenue,2025-05-31,565137,1066231,9000000
|
||||
1,Total Revenue,2025-06-30,626024,1692255,9000000
|
||||
1,Total Revenue,2025-07-31,748998,2441252,9000000
|
||||
1,Total Revenue,2025-08-31,779353,3220605,9000000
|
||||
1,Total Revenue,2025-09-30,665206,3885811,9000000
|
||||
1,Total Revenue,2025-10-31,728266,4614078,9000000
|
||||
1,Total Revenue,2025-11-30,664032,5278109,9000000
|
||||
1,Total Revenue,2025-12-31,766894,6045003,9000000
|
||||
1,Total Revenue,2026-01-31,862453,6907456,9000000
|
||||
1,Total Revenue,2026-02-28,943922,7851378,9000000
|
||||
1,Total Revenue,2026-03-31,1148622,9000000,9000000
|
||||
2,Revenue Retained Post-Resolutions,2025-01-31,350000,2210000,2800000
|
||||
2,Revenue Retained Post-Resolutions,2025-02-28,257815,2467815,2800000
|
||||
2,Revenue Retained Post-Resolutions,2025-03-31,332185,2800000,2800000
|
||||
2,Revenue Retained Post-Resolutions,2025-04-30,249512,249512,3800000
|
||||
2,Revenue Retained Post-Resolutions,2025-05-31,264000,513512,3800000
|
||||
2,Revenue Retained Post-Resolutions,2025-06-30,293928,807440,3800000
|
||||
2,Revenue Retained Post-Resolutions,2025-07-31,311830,1119270,3800000
|
||||
2,Revenue Retained Post-Resolutions,2025-08-31,359278,1478547,3800000
|
||||
2,Revenue Retained Post-Resolutions,2025-09-30,275513,1754060,3800000
|
||||
2,Revenue Retained Post-Resolutions,2025-10-31,301654,2055714,3800000
|
||||
2,Revenue Retained Post-Resolutions,2025-11-30,254674,2310388,3800000
|
||||
2,Revenue Retained Post-Resolutions,2025-12-31,324301,2634689,3800000
|
||||
2,Revenue Retained Post-Resolutions,2026-01-31,354507,2989197,3800000
|
||||
2,Revenue Retained Post-Resolutions,2026-02-28,367995,3357192,3800000
|
||||
2,Revenue Retained Post-Resolutions,2026-03-31,442809,3800000,3800000
|
||||
6,Billable Bookings,2025-01-31,26756,226841,308000
|
||||
6,Billable Bookings,2025-02-28,36445,263285,308000
|
||||
6,Billable Bookings,2025-03-31,44715,308000,308000
|
||||
6,Billable Bookings,2025-04-30,19096,19096,450000
|
||||
6,Billable Bookings,2025-05-31,20558,39654,450000
|
||||
6,Billable Bookings,2025-06-30,21879,61533,450000
|
||||
6,Billable Bookings,2025-07-31,44239,105771,450000
|
||||
6,Billable Bookings,2025-08-31,43567,149338,450000
|
||||
6,Billable Bookings,2025-09-30,36885,186223,450000
|
||||
6,Billable Bookings,2025-10-31,37935,224158,450000
|
||||
6,Billable Bookings,2025-11-30,35388,259546,450000
|
||||
6,Billable Bookings,2025-12-31,36991,296537,450000
|
||||
6,Billable Bookings,2026-01-31,39541,336078,450000
|
||||
6,Billable Bookings,2026-02-28,50904,386982,450000
|
||||
6,Billable Bookings,2026-03-31,63018,450000,450000
|
||||
10,Damage Waiver Payout Rate,2025-01-31,0.65,0.65,0.65
|
||||
10,Damage Waiver Payout Rate,2025-02-28,0.65,0.65,0.65
|
||||
10,Damage Waiver Payout Rate,2025-03-31,0.65,0.65,0.65
|
||||
10,Damage Waiver Payout Rate,2025-04-30,0.58,0.58,0.58
|
||||
10,Damage Waiver Payout Rate,2025-05-31,0.58,0.58,0.58
|
||||
10,Damage Waiver Payout Rate,2025-06-30,0.58,0.58,0.58
|
||||
10,Damage Waiver Payout Rate,2025-07-31,0.58,0.58,0.58
|
||||
10,Damage Waiver Payout Rate,2025-08-31,0.58,0.58,0.58
|
||||
10,Damage Waiver Payout Rate,2025-09-30,0.58,0.58,0.58
|
||||
10,Damage Waiver Payout Rate,2025-10-31,0.58,0.58,0.58
|
||||
10,Damage Waiver Payout Rate,2025-11-30,0.58,0.58,0.58
|
||||
10,Damage Waiver Payout Rate,2025-12-31,0.58,0.58,0.58
|
||||
10,Damage Waiver Payout Rate,2026-01-31,0.58,0.58,0.58
|
||||
10,Damage Waiver Payout Rate,2026-02-28,0.58,0.58,0.58
|
||||
10,Damage Waiver Payout Rate,2026-03-31,0.58,0.58,0.58
|
||||
11,Host Resolutions Payout Rate,2025-01-31,0.11,0.11,0.11
|
||||
11,Host Resolutions Payout Rate,2025-02-28,0.11,0.11,0.11
|
||||
11,Host Resolutions Payout Rate,2025-03-31,0.11,0.11,0.11
|
||||
11,Host Resolutions Payout Rate,2025-04-30,0.10,0.10,0.10
|
||||
11,Host Resolutions Payout Rate,2025-05-31,0.10,0.10,0.10
|
||||
11,Host Resolutions Payout Rate,2025-06-30,0.10,0.10,0.10
|
||||
11,Host Resolutions Payout Rate,2025-07-31,0.10,0.10,0.10
|
||||
11,Host Resolutions Payout Rate,2025-08-31,0.10,0.10,0.10
|
||||
11,Host Resolutions Payout Rate,2025-09-30,0.10,0.10,0.10
|
||||
11,Host Resolutions Payout Rate,2025-10-31,0.10,0.10,0.10
|
||||
11,Host Resolutions Payout Rate,2025-11-30,0.10,0.10,0.10
|
||||
11,Host Resolutions Payout Rate,2025-12-31,0.10,0.10,0.10
|
||||
11,Host Resolutions Payout Rate,2026-01-31,0.10,0.10,0.10
|
||||
11,Host Resolutions Payout Rate,2026-02-28,0.10,0.10,0.10
|
||||
11,Host Resolutions Payout Rate,2026-03-31,0.10,0.10,0.10
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue