Relative increments with sign
This commit is contained in:
parent
fdec616fe6
commit
f5718ded4d
4 changed files with 159 additions and 27 deletions
|
|
@ -8,6 +8,7 @@
|
|||
"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,
|
||||
|
|
@ -18,6 +19,7 @@
|
|||
"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,
|
||||
|
|
@ -28,6 +30,7 @@
|
|||
"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,
|
||||
|
|
@ -38,6 +41,7 @@
|
|||
"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,
|
||||
|
|
@ -48,6 +52,7 @@
|
|||
"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,
|
||||
|
|
@ -58,6 +63,7 @@
|
|||
"current_YTD": "current_ytd_billable_bookings",
|
||||
"previous_YTD": "previous_ytd_billable_bookings",
|
||||
"display_exclusion": "NONE",
|
||||
"increment_sign_format": "POSITIVE",
|
||||
},
|
||||
{
|
||||
"id_metric": 7,
|
||||
|
|
@ -68,6 +74,7 @@
|
|||
"current_YTD": "current_ytd_live_deals",
|
||||
"previous_YTD": "previous_ytd_live_deals",
|
||||
"display_exclusion": "NONE",
|
||||
"increment_sign_format": "POSITIVE",
|
||||
},
|
||||
{
|
||||
"id_metric": 8,
|
||||
|
|
@ -78,6 +85,7 @@
|
|||
"current_YTD": "current_ytd_new_deals",
|
||||
"previous_YTD": "previous_ytd_new_deals",
|
||||
"display_exclusion": "NONE",
|
||||
"increment_sign_format": "POSITIVE",
|
||||
},
|
||||
{
|
||||
"id_metric": 9,
|
||||
|
|
@ -88,6 +96,7 @@
|
|||
"current_YTD": "current_ytd_churning_deals",
|
||||
"previous_YTD": "previous_ytd_churning_deals",
|
||||
"display_exclusion": "NONE",
|
||||
"increment_sign_format": "NEGATIVE",
|
||||
},
|
||||
{
|
||||
"id_metric": 10,
|
||||
|
|
@ -98,6 +107,7 @@
|
|||
"current_YTD": "current_ytd_waiver_payout_rate",
|
||||
"previous_YTD": "previous_ytd_waiver_payout_rate",
|
||||
"display_exclusion": "INVOICING",
|
||||
"increment_sign_format": "NEGATIVE",
|
||||
},
|
||||
{
|
||||
"id_metric": 11,
|
||||
|
|
@ -108,6 +118,7 @@
|
|||
"current_YTD": "current_ytd_resolutions_payout_rate",
|
||||
"previous_YTD": "previous_ytd_resolutions_payout_rate",
|
||||
"display_exclusion": "INVOICING",
|
||||
"increment_sign_format": "NEGATIVE",
|
||||
},
|
||||
{
|
||||
"id_metric": 12,
|
||||
|
|
@ -118,6 +129,7 @@
|
|||
"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,
|
||||
|
|
@ -128,6 +140,7 @@
|
|||
"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,
|
||||
|
|
@ -138,6 +151,7 @@
|
|||
"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,
|
||||
|
|
@ -148,6 +162,7 @@
|
|||
"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,
|
||||
|
|
@ -158,6 +173,7 @@
|
|||
"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,
|
||||
|
|
@ -168,6 +184,7 @@
|
|||
"current_YTD": "current_ytd_onboarding_mrr",
|
||||
"previous_YTD": "previous_ytd_onboarding_mrr",
|
||||
"display_exclusion": "ONGOING_MONTH",
|
||||
"increment_sign_format": "POSITIVE",
|
||||
},
|
||||
] %}
|
||||
with
|
||||
|
|
@ -190,6 +207,7 @@ 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,
|
||||
|
|
@ -216,30 +234,63 @@ 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.*,
|
||||
-- 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)
|
||||
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
|
||||
|
|
|
|||
|
|
@ -2664,3 +2664,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.
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue