Compare commits

...

3 Commits

Author SHA1 Message Date
b0234c2f89 Merge branch 'dev' 2021-07-30 08:16:07 -04:00
b2147b0a02 increment snapshot period 2021-07-30 08:15:48 -04:00
ed1cd2b074 change iterations in monthly adjustments 2021-07-30 12:13:34 +00:00
3 changed files with 6 additions and 6 deletions

View File

@ -21,7 +21,7 @@ tdr AS (
DATERANGE('2021-06-01','2022-06-01','[)') prange
-----------explicitly call out overlap period------------------------
-----------anythign in this period has to net out to match actuals---
,DATERANGE('2021-06-01','2021-07-12','[]') overlap
,DATERANGE('2021-06-01','2021-07-29','[]') overlap
,jsonb_build_array('plan','diff') iter
)
,booked AS materialized(

View File

@ -16,19 +16,19 @@ DROP TABLE IF EXISTS tdr;
CREATE TEMP TABLE tdr AS (
SELECT
-----------actuals into baseline-------------------------------------
DATERANGE('2020-06-01','2021-07-15','[]') arange
DATERANGE('2020-06-01','2021-07-29','[]') arange
-----------plan into baseline----------------------------------------
,DATERANGE('2020-06-01','2022-06-01','[)') prange
-----------forecast into baseline------------------------------------
,DATERANGE('2022-06-01','2022-06-01','[)') frange -- this range effectively excludes
-----------baseline selection for increment--------------------------
,DATERANGE('2021-07-15','2021-07-15','[)') selection
,DATERANGE('2021-07-29','2021-07-29','[)') selection
-----------selection increment size----------------------------------
,'0 year'::interval AS incr
-----------iterations to merge with----------------------------------
,(SELECT jsonb_agg(x.v) FROM (VALUES('copy'),('actuals'),('actuals_plug')) AS x(v)) iter
-----------existing baseline overlap---------------------------------
,DATERANGE('2000-06-01','2021-07-08') overlap
,DATERANGE('2000-06-01','2021-07-29') overlap
);
--select * from tdr

View File

@ -96,11 +96,11 @@ GROUP BY
,seq
,SUM(units) FILTER (WHERE order_season = 2021) "2021 qty"
,SUM(units) FILTER (WHERE order_season = 2022 AND iter IN ('copy','short ship','bad_ship','plan')) "2022 base qty"
,SUM(units) FILTER (WHERE order_season = 2022 AND iter NOT IN ('copy','short ship','bad_ship','diff','pf')) "2022 adj qty"
,SUM(units) FILTER (WHERE order_season = 2022 AND iter NOT IN ('copy','short ship','bad_ship','plan')) "2022 adj qty"
,SUM(units) FILTER (WHERE order_season = 2022) "2022 tot qty"
,SUM(value_usd) FILTER (WHERE order_season = 2021) "2021 value_usd"
,SUM(value_usd) FILTER (WHERE order_season = 2022 AND iter IN ('copy','short ship','bad_ship','plan')) "2022 base value_usd"
,SUM(value_usd) FILTER (WHERE order_season = 2022 AND iter NOT IN ('copy','short ship','bad_ship','diff','pf')) "2022 adj value_usd"
,SUM(value_usd) FILTER (WHERE order_season = 2022 AND iter NOT IN ('copy','short ship','bad_ship','plan')) "2022 adj value_usd"
,SUM(value_usd) FILTER (WHERE order_season = 2022) "2022 tot value_usd"
FROM
months