Merged PR 5586: Fix duplications on 1st of Month for Billable Items Growth Score
# Description This relates to today's data alerts on Growth Score models. Error has been found in `int_billable_items_growth_score_by_deal`. This only happens on the 1st of the month. On the 1st day of the month we will have: * The actual monthly data from KPIs in the previous month. But also: * Projected KPIs will still display data for the previous month, in this case though, projected = actuals. There's a union all that combines actual monthly KPI data for history purposes and the projected data which fails in this case. Fix is to remove the data from Projected KPIs if the current date of execution (1st of July) equals the first day of the month when computing `end_date` + 1 day. End date being at this moment 30th of June, + 1 day = 1st of July, extracting the first day of the month then 1st July. # Checklist - [X] The edited models and dependants run properly with production data. - [X] The edited models are sufficiently documented. - [X] The edited models contain PK tests, and I've ran and passed them. - [NA] I have checked for DRY opportunities with other models and docs. - [NA] I've picked the right materialization for the affected models. # Other - [ ] Check if a full-refresh is required after this PR is merged. Related work items: #31665
This commit is contained in:
parent
7bf9168796
commit
412e242f42
1 changed files with 6 additions and 0 deletions
|
|
@ -45,6 +45,12 @@ with
|
||||||
as projection_mean_absolute_percentage_error,
|
as projection_mean_absolute_percentage_error,
|
||||||
true as are_billable_items_projected
|
true as are_billable_items_projected
|
||||||
from int_kpis_projected__agg_monthly_billable_items
|
from int_kpis_projected__agg_monthly_billable_items
|
||||||
|
-- The following condition forces the exclusion of projected data on the 1st
|
||||||
|
-- day of the month to avoid duplicates:
|
||||||
|
-- On the 1st day of the month we will already have the actual Billable Items
|
||||||
|
-- of the previous month. In this case, the projected items are equal to the
|
||||||
|
-- actual, and it creates duplicates.
|
||||||
|
where current_date <> date_trunc('month', end_date + interval '1 day')::date
|
||||||
union all
|
union all
|
||||||
select
|
select
|
||||||
start_date,
|
start_date,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue