fde6c97964
A lot has changed here, including: 1. Adding pounds to the data available for display in pivot table. 2. Visual improvements 3. Code simplification 4. Hiding / showing sheets as needed. A developer's backdoor allows for easy toggling for debugging purposes: Ctrl+RightClick on the Forecast Adjustment form's "Selected Scenario" label. 5. Fixed a bug that happened when deleting rows from the basket. The definition of the Target variable was lost in some cases. 6. Made use of the Cancel and Default form properties to purge some unnecessary code. 7. Added a sheet that contains Help text for the users. 8. Replacing more harcoded range reference with range names. 9. Refactor checks for division by zero errors, and improve error messages for users. 10. Remove manual formatting. It's already done and saved in the workbook; there's no need to redo it in code. 11. Added more data validation before Save operation proceeds. 12. Added a new IntersectsWith function to simplify If statements.
93 lines
1.6 KiB
SQL
93 lines
1.6 KiB
SQL
WITH rows AS (
|
|
SELECT
|
|
---------customer info-----------------
|
|
bill_cust_descr
|
|
,billto_group
|
|
,ship_cust_descr
|
|
,shipto_group
|
|
,quota_rep_descr
|
|
,director
|
|
,segm
|
|
,substance
|
|
,chan
|
|
,chansub
|
|
---------product info------------------
|
|
,majg_descr
|
|
,ming_descr
|
|
,majs_descr
|
|
,mins_descr
|
|
--,brand
|
|
--,part_family
|
|
,part_group
|
|
,branding
|
|
--,color
|
|
,part_descr
|
|
---------dates-------------------------
|
|
,order_season
|
|
,order_month
|
|
,ship_season
|
|
,ship_month
|
|
,request_season
|
|
,request_month
|
|
,promo
|
|
--------values-------------------------
|
|
,sum(value_loc) value_loc
|
|
,sum(value_usd) value_usd
|
|
,sum(cost_loc) cost_loc
|
|
,sum(cost_usd) cost_usd
|
|
,sum(units) units
|
|
,sum(pounds) pounds
|
|
,version
|
|
,iter
|
|
,logid
|
|
,tag
|
|
,comment
|
|
FROM
|
|
rlarp.osm_pool
|
|
WHERE
|
|
quota_rep_descr = 'rep_replace'
|
|
GROUP BY
|
|
---------customer info-----------------
|
|
bill_cust_descr
|
|
,billto_group
|
|
,ship_cust_descr
|
|
,shipto_group
|
|
,quota_rep_descr
|
|
,director
|
|
,segm
|
|
,substance
|
|
,chan
|
|
,chansub
|
|
---------product info------------------
|
|
,majg_descr
|
|
,ming_descr
|
|
,majs_descr
|
|
,mins_descr
|
|
--,brand
|
|
--,part_family
|
|
,part_group
|
|
,branding
|
|
--,color
|
|
,part_descr
|
|
---------dates-------------------------
|
|
,order_season
|
|
,order_month
|
|
,ship_season
|
|
,ship_month
|
|
,request_season
|
|
,request_month
|
|
,promo
|
|
,version
|
|
,iter
|
|
,logid
|
|
,tag
|
|
,comment
|
|
,substance
|
|
ORDER BY
|
|
logid ASC
|
|
)
|
|
SELECT
|
|
json_agg(row_to_json(rows)) x
|
|
FROM
|
|
rows
|