diff --git a/macros/is_date_before_20th_of_previous_month.sql b/macros/is_date_before_12th_of_previous_month.sql similarity index 69% rename from macros/is_date_before_20th_of_previous_month.sql rename to macros/is_date_before_12th_of_previous_month.sql index bba73e9..fc37634 100644 --- a/macros/is_date_before_20th_of_previous_month.sql +++ b/macros/is_date_before_12th_of_previous_month.sql @@ -2,23 +2,23 @@ This macro returns a boolean value for dates depending on the current day of the month Logic: -- If today is the 20th or later of the current month: +- If today is the 12th or later of the current month: - Returns **False** for all dates within the current month. - Returns **True** for dates before the current month. -- If today is before the 20th: +- If today is before the 12th: - Returns **False** for all dates within the current and previous month. - Returns **True** for dates before the previous month. */ -{% macro is_date_before_20th_of_previous_month(date) %} +{% macro is_date_before_12th_of_previous_month(date) %} ( case - -- If today is the 20th or later, only exclude current month - when extract(day from now()) >= 20 + -- If today is the 12th or later, only exclude current month + when extract(day from now()) >= 12 then date_trunc('month', ({{ date }})::date)::date < date_trunc('month', now())::date - -- If today is before the 20th, exclude both current and previous month + -- If today is before the 12th, exclude both current and previous month else date_trunc('month', ({{ date }})::date)::date < date_trunc('month', now() - interval '1 month')::date diff --git a/models/reporting/general/mtd_aggregated_metrics.sql b/models/reporting/general/mtd_aggregated_metrics.sql index ef7a94e..0593dca 100644 --- a/models/reporting/general/mtd_aggregated_metrics.sql +++ b/models/reporting/general/mtd_aggregated_metrics.sql @@ -55,11 +55,11 @@ where ( ( -- Not show current + previous month if the metric depends on - -- 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 + -- invoicing cycle and it is before the 12th of the month, if it + -- is the 12th of the month or after, only exclude the current -- month. display_exclusion = 'INVOICING' - and {{ is_date_before_20th_of_previous_month("date") }} + and {{ is_date_before_12th_of_previous_month("date") }} ) or ( -- Handle exclusion for Churn/MRR metrics: do not show them in the diff --git a/models/reporting/general/mtd_aggregated_metrics_by_deal.sql b/models/reporting/general/mtd_aggregated_metrics_by_deal.sql index fdc81ca..376645d 100644 --- a/models/reporting/general/mtd_aggregated_metrics_by_deal.sql +++ b/models/reporting/general/mtd_aggregated_metrics_by_deal.sql @@ -47,11 +47,11 @@ where ( ( -- Not show current + previous month if the metric depends on - -- 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 + -- invoicing cycle and it is before the 12th of the month, if it + -- is the 12th of the month or after, only exclude the current -- month. m.display_exclusion = 'INVOICING' - and {{ is_date_before_20th_of_previous_month("m.date") }} + and {{ is_date_before_12th_of_previous_month("m.date") }} ) or ( -- Handle exclusion for Churn/MRR metrics: do not show them in the diff --git a/models/reporting/general/ytd_mtd_aggregated_main_metrics_overview.sql b/models/reporting/general/ytd_mtd_aggregated_main_metrics_overview.sql index 0989bf1..5e8e395 100644 --- a/models/reporting/general/ytd_mtd_aggregated_main_metrics_overview.sql +++ b/models/reporting/general/ytd_mtd_aggregated_main_metrics_overview.sql @@ -10,11 +10,11 @@ with ( ( -- Not show current + previous month if the metric depends on - -- 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 + -- invoicing cycle and it is before the 12th of the month, if it + -- is the 12th of the month or after, only exclude the current -- month. display_exclusion = 'INVOICING' - and {{ is_date_before_20th_of_previous_month("date") }} + and {{ is_date_before_12th_of_previous_month("date") }} ) or ( -- Handle exclusion for Churn/MRR metrics: do not show them in the