diff --git a/models/intermediate/kpis/int_kpis__product_guest_agg_metrics.sql b/models/intermediate/kpis/int_kpis__product_guest_agg_metrics.sql index 5a1c5b5..f99c1f7 100644 --- a/models/intermediate/kpis/int_kpis__product_guest_agg_metrics.sql +++ b/models/intermediate/kpis/int_kpis__product_guest_agg_metrics.sql @@ -33,7 +33,7 @@ with date_trunc('week', {{ yesterday }} - interval '1 year') as py_week_start, -- Start of the same week last year date_trunc('week', {{ yesterday }} - interval '1 year') + ( {{ yesterday }} - date_trunc('week', {{ yesterday }}) - ) as py_week_current_date, + ) as py_week_current_date, -- Start of the same week in the previous year date_trunc('week', {{ yesterday }} - interval '1 week') as pp_week_start, -- Start of the same week in the previous period date_trunc('month', {{ yesterday }} - interval '1 year') as py_month_start, date_trunc('year', {{ yesterday }}) as current_year_start, @@ -72,7 +72,7 @@ with end ) as pp_value from int_kpis__product_guest_daily_metrics dm, date_ranges dr - where extract(day from date_day) <= dr.current_day_of_month + where dm.date_day >= dr.py_year_start group by metric, has_payment, has_id_check, main_billing_country_iso_3_per_deal union all @@ -101,7 +101,9 @@ with end ) as pp_value from int_kpis__product_guest_daily_metrics dm, date_ranges dr - where extract(day from date_day) <= dr.current_day_of_month + where + dm.date_day >= dr.py_month_start + and extract(day from date_day) <= dr.current_day_of_month group by metric, has_payment, has_id_check, main_billing_country_iso_3_per_deal union all