Today's fun formula for the day: ```sum/* comment ...
# suiteanalytics
k
Today's fun formula for the day:
Copy code
sum/* comment */(case {transaction.type} when  'Purchase Order' then ({transaction.quantity}-nvl({transaction.quantityshiprecv},0)) when 'Sales Order' then -({transaction.quantity}-nvl({transaction.quantityshiprecv},0)) else 0 end)    OVER(PARTITION BY {internalid},{transaction.location}    ORDER BY  {transaction.trandate}  ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) +nvl({locationquantityonhand},0)
Calculating Expected Quantity on hand by Date on Transactions.
😀 1
v
ooooh lemme find you one of the ones from my predecessors
this is because those who came before didn't know about the native quota functionality and decided to come up with custom quotas via saved search formulas
(CASE WHEN NVL(SUM((CASE WHEN {transaction.type} in ('Invoice','Credit Memo') AND {transaction.trandate} >= ADD_MONTHS(TRUNC({today}, 'MONTH'), -12) AND {transaction.trandate} < ADD_MONTHS(TRUNC({today},'MONTH'), -11) THEN {transaction.amount}  - NVL({transaction.shippingamount},0) - NVL({transaction.taxamount},0) ELSE 0 END)*(1 + {salesrep.custentity_hub_sales_quota_p})),0) = 0 THEN 1 WHEN (SUM(CASE WHEN {transaction.type} in ('Invoice','Credit Memo') AND {transaction.trandate} >= TRUNC({today}, 'MONTH') THEN {transaction.amount} - NVL({transaction.shippingamount},0) - NVL({transaction.taxamount},0) ELSE 0 END)) = 0 THEN -1 ELSE (SUM(CASE WHEN {transaction.type} in ('Invoice','Credit Memo') AND {transaction.trandate} >= TRUNC({today}, 'MONTH') THEN {transaction.amount} - NVL({transaction.shippingamount},0) - NVL({transaction.taxamount},0) ELSE 0 END) - SUM((CASE WHEN {transaction.type} in ('Invoice','Credit Memo') AND {transaction.trandate} >= ADD_MONTHS(TRUNC({today}, 'MONTH'), -12) AND {transaction.trandate} < ADD_MONTHS(TRUNC({today},'MONTH'), -11) THEN {transaction.amount}  - NVL({transaction.shippingamount},0) - NVL({transaction.taxamount},0) ELSE 0 END)*(1 + {salesrep.custentity_hub_sales_quota_p})))/ABS(SUM((CASE WHEN {transaction.type} in ('Invoice','Credit Memo') AND {transaction.trandate} >= ADD_MONTHS(TRUNC({today}, 'MONTH'), -12) AND {transaction.trandate} < ADD_MONTHS(TRUNC({today},'MONTH'), -11) THEN {transaction.amount}  - NVL({transaction.shippingamount},0) - NVL({transaction.taxamount},0) ELSE 0 END)*(1 + {salesrep.custentity_hub_sales_quota_p})))END)+1
👀 1
look at the length on that bad larry
k
Seems like a lot of the same logic over and over.