Merged PR 4500: Revert "Relative increments with sign"

# Description

_Describe your motivation and changes here._

# Checklist

- [ ] The edited models and dependants run properly with production data.
- [ ] The edited models are sufficiently documented.
- [ ] The edited models contain PK tests, and I've ran and passed them.
- [ ] I have checked for DRY opportunities with other models and docs.
- [ ] I've picked the right materialization for the affected models.

# Other

- [ ] Check if a full-refresh is required after this PR is merged.

Revert "Relative increments with sign"

Reverted commit `f5718ded`.
This commit is contained in:
Oriol Roqué Paniagua 2025-02-25 11:43:05 +00:00
parent f5718ded4d
commit 5eebb4f560
4 changed files with 27 additions and 159 deletions

View file

@ -8,7 +8,6 @@
"current_YTD": "current_ytd_total_revenue_in_gbp",
"previous_YTD": "previous_ytd_total_revenue_in_gbp",
"display_exclusion": "INVOICING",
"increment_sign_format": "POSITIVE",
},
{
"id_metric": 2,
@ -19,7 +18,6 @@
"current_YTD": "current_ytd_revenue_retained_post_resolutions_in_gbp",
"previous_YTD": "previous_ytd_revenue_retained_post_resolutions_in_gbp",
"display_exclusion": "INVOICING",
"increment_sign_format": "POSITIVE",
},
{
"id_metric": 3,
@ -30,7 +28,6 @@
"current_YTD": "current_ytd_total_guest_payments_in_gbp",
"previous_YTD": "previous_ytd_total_guest_payments_in_gbp",
"display_exclusion": "NONE",
"increment_sign_format": "POSITIVE",
},
{
"id_metric": 4,
@ -41,7 +38,6 @@
"current_YTD": "current_ytd_xero_operator_net_fees_in_gbp",
"previous_YTD": "previous_ytd_xero_operator_net_fees_in_gbp",
"display_exclusion": "INVOICING",
"increment_sign_format": "POSITIVE",
},
{
"id_metric": 5,
@ -52,7 +48,6 @@
"current_YTD": "current_ytd_xero_apis_net_fees_in_gbp",
"previous_YTD": "previous_ytd_xero_apis_net_fees_in_gbp",
"display_exclusion": "INVOICING",
"increment_sign_format": "POSITIVE",
},
{
"id_metric": 6,
@ -63,7 +58,6 @@
"current_YTD": "current_ytd_billable_bookings",
"previous_YTD": "previous_ytd_billable_bookings",
"display_exclusion": "NONE",
"increment_sign_format": "POSITIVE",
},
{
"id_metric": 7,
@ -74,7 +68,6 @@
"current_YTD": "current_ytd_live_deals",
"previous_YTD": "previous_ytd_live_deals",
"display_exclusion": "NONE",
"increment_sign_format": "POSITIVE",
},
{
"id_metric": 8,
@ -85,7 +78,6 @@
"current_YTD": "current_ytd_new_deals",
"previous_YTD": "previous_ytd_new_deals",
"display_exclusion": "NONE",
"increment_sign_format": "POSITIVE",
},
{
"id_metric": 9,
@ -96,7 +88,6 @@
"current_YTD": "current_ytd_churning_deals",
"previous_YTD": "previous_ytd_churning_deals",
"display_exclusion": "NONE",
"increment_sign_format": "NEGATIVE",
},
{
"id_metric": 10,
@ -107,7 +98,6 @@
"current_YTD": "current_ytd_waiver_payout_rate",
"previous_YTD": "previous_ytd_waiver_payout_rate",
"display_exclusion": "INVOICING",
"increment_sign_format": "NEGATIVE",
},
{
"id_metric": 11,
@ -118,7 +108,6 @@
"current_YTD": "current_ytd_resolutions_payout_rate",
"previous_YTD": "previous_ytd_resolutions_payout_rate",
"display_exclusion": "INVOICING",
"increment_sign_format": "NEGATIVE",
},
{
"id_metric": 12,
@ -129,7 +118,6 @@
"current_YTD": "current_ytd_operator_revenue_per_billable_booking",
"previous_YTD": "previous_ytd_operator_revenue_per_billable_booking",
"display_exclusion": "INVOICING",
"increment_sign_format": "POSITIVE",
},
{
"id_metric": 13,
@ -140,7 +128,6 @@
"current_YTD": "current_ytd_waiver_revenue_per_billable_booking",
"previous_YTD": "previous_ytd_waiver_revenue_per_billable_booking",
"display_exclusion": "NONE",
"increment_sign_format": "POSITIVE",
},
{
"id_metric": 14,
@ -151,7 +138,6 @@
"current_YTD": "-1*current_ytd_xero_waiver_paid_back_to_host_in_gbp",
"previous_YTD": "-1*previous_ytd_xero_waiver_paid_back_to_host_in_gbp",
"display_exclusion": "INVOICING",
"increment_sign_format": "NEGATIVE",
},
{
"id_metric": 15,
@ -162,7 +148,6 @@
"current_YTD": "-1*current_ytd_xero_host_resolution_amount_paid_in_gbp",
"previous_YTD": "-1*previous_ytd_xero_host_resolution_amount_paid_in_gbp",
"display_exclusion": "INVOICING",
"increment_sign_format": "NEGATIVE",
},
{
"id_metric": 16,
@ -173,7 +158,6 @@
"current_YTD": "current_ytd_total_revenue_churn_rate",
"previous_YTD": "previous_ytd_total_revenue_churn_rate",
"display_exclusion": "ONGOING_MONTH",
"increment_sign_format": "NEGATIVE",
},
{
"id_metric": 17,
@ -184,7 +168,6 @@
"current_YTD": "current_ytd_onboarding_mrr",
"previous_YTD": "previous_ytd_onboarding_mrr",
"display_exclusion": "ONGOING_MONTH",
"increment_sign_format": "POSITIVE",
},
] %}
with
@ -207,7 +190,6 @@ with
-- quotation marks added because text format
'{{ metric.name }}' as metric_name,
'{{ metric.display_exclusion }}' as display_exclusion,
'{{ metric.increment_sign_format }}' as increment_sign_format,
{{ metric.current_month_MTD }} as current_month_mtd,
{{ metric.previous_month_EOM }} as previous_month_eom,
{{ metric.previous_year_MTD }} as previous_year_mtd,
@ -234,63 +216,30 @@ with
union all
{% endif %}
{% endfor %}
),
metrics_with_targets as (
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)
)
select
metrics_with_targets.*,
-- Add sign to relative differences --
case
when increment_sign_format = 'NEGATIVE'
then rel_diff_current_month_mtd_vs_previous_month_eom * -1
else rel_diff_current_month_mtd_vs_previous_month_eom
end as rel_diff_with_sign_current_month_mtd_vs_previous_month_eom,
case
when increment_sign_format = 'NEGATIVE'
then rel_diff_current_month_mtd_vs_previous_year_mtd * -1
else rel_diff_current_month_mtd_vs_previous_year_mtd
end as rel_diff_with_sign_current_month_mtd_vs_previous_year_mtd,
case
when increment_sign_format = 'NEGATIVE'
then rel_diff_current_ytd_vs_previous_ytd * -1
else rel_diff_current_ytd_vs_previous_ytd
end as rel_diff_with_sign_current_ytd_vs_previous_ytd,
case
when increment_sign_format = 'NEGATIVE'
then rel_diff_current_month_mtd_vs_eom_target * -1
else rel_diff_current_month_mtd_vs_eom_target
end as rel_diff_with_sign_current_month_mtd_vs_eom_target,
case
when increment_sign_format = 'NEGATIVE'
then rel_diff_current_ytd_vs_ytd_target * -1
else rel_diff_current_ytd_vs_ytd_target
end as rel_diff_with_sign_current_ytd_vs_ytd_target
from metrics_with_targets
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)

View file

@ -2664,38 +2664,3 @@ 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

@ -2131,38 +2131,3 @@ 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,8 +3,7 @@ with
select * from {{ ref("int_ytd_mtd_aggregated_main_metrics_overview") }}
),
latest_dates_per_financial_year as (
select
dimension, financial_year, id_metric, max(m.date) as latest_available_date
select dimension, financial_year, id_metric, max(date) as latest_available_date
from int_ytd_mtd_aggregated_main_metrics_overview m
where
(
@ -64,17 +63,7 @@ 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,
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
as achievement_rate_current_ytd_vs_eofy_target
from int_ytd_mtd_aggregated_main_metrics_overview m
inner join
latest_dates_per_financial_year ld