Refactor display exclusion for clarity purposes

This commit is contained in:
uri 2025-02-25 11:45:14 +01:00
parent dab210c607
commit fdec616fe6
3 changed files with 37 additions and 33 deletions

View file

@ -4,7 +4,7 @@ with
),
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
from int_ytd_mtd_aggregated_main_metrics_overview m
where
(
(
@ -12,20 +12,18 @@ with
-- invoicing cycle and it is before the 20th of the month, if it
-- is the 20th of the month or after, only exclude the current
-- month.
requires_invoicing_data = true
display_exclusion = 'INVOICING'
and {{ is_date_before_20th_of_previous_month("date") }}
)
-- Keep all history for the rest of metrics
or requires_invoicing_data = false
)
-- Handle exclusion for Churn/MRR metrics: do not show them in the current
-- month.
and not (
(
lower(metric_name) like '%revenue%churn%rate%'
or lower(metric_name) like '%onboarding%mrr%'
or (
-- Handle exclusion for Churn/MRR metrics: do not show them in the
-- current
-- month.
display_exclusion = 'ONGOING_MONTH'
and date_trunc('month', m.date) > date_trunc('month', current_date)
)
and date_trunc('month', "date") = date_trunc('month', current_date)
-- Keep all history for the rest of metrics
or display_exclusion = 'NONE'
)
group by dimension, financial_year, id_metric
)