I have a formula field in a transaction saved sear...
# general
b
I have a formula field in a transaction saved search that seems to not be giving the correct results a majority of the time. I can't pinpoint why it works for some transactions and not for others. Can someone tell me if this formula looks correct? The "custcol_css_grant1" (and grant2 and grant3) fields are just custom transaction line fields that hold an amount a user assigns to them. We are aiming for the total of these three custom fields to be equal to the amount field (Completely Assigned). CASE WHEN (NVL({custcol_css_grant1_amt}, 0) + NVL({custcol_css_grant2_amt}, 0) + NVL({custcol_css_grant3_amt}, 0) >= {amount} AND {amount} > 0) THEN 'Completely Assigned' WHEN ((NVL({custcol_css_grant1_amt}, 0) + NVL({custcol_css_grant2_amt}, 0) + NVL({custcol_css_grant3_amt}, 0) < {amount}) AND (NVL({custcol_css_grant1_amt}, 0) + NVL({custcol_css_grant2_amt}, 0) + NVL({custcol_css_grant3_amt}, 0)) > 0) THEN 'Partially Assigned' WHEN NVL({custcol_css_grant1_amt}, 0) + NVL({custcol_css_grant2_amt}, 0) + NVL({custcol_css_grant3_amt}, 0) = 0 THEN 'Unassigned' WHEN ({custcol_css_grant1} = '' AND {custcol_css_grant2} = '' AND {custcol_css_grant3} = '') THEN 'Unassigned' END
k
I'd probably do something more like this
Copy code
CASE 
WHEN (NVL({custcol_css_grant1_amt}, 0) + NVL({custcol_css_grant2_amt}, 0) + NVL({custcol_css_grant3_amt}, 0) 
>= {amount} AND {amount} > 0) 
THEN 'Completely Assigned' 
WHEN  
((NVL({custcol_css_grant1_amt}, 0) + NVL({custcol_css_grant2_amt}, 0) + NVL({custcol_css_grant3_amt}, 0) < {amount})  AND (NVL({custcol_css_grant1_amt}, 0) + NVL({custcol_css_grant2_amt}, 0) + NVL({custcol_css_grant3_amt}, 0)) > 0) 
THEN 'Partially Assigned' 
else 'Unassigned' END
b
Thanks @KevinJ of Kansas but that didn't seem to make a difference. They are still showing as "partially assigned" when they should be "completely assigned." Back to the drawing board I guess!
k
Oh
I didn't understand the requirement fully...
can you share some values form one that is showing as partially assigned?
b
(I didn't explain it very well looking back at what I wrote yesterday)
k
are you sure you don't have some rounding errors in play?
i.e. 23.555 would show as 23.56 - but when adding them together it would treat it as 23.555
if you had a threshold where you consider something fully covered, let's say a dollar difference you could bake that into your formula
Copy code
CASE 
WHEN (NVL({custcol_css_grant1_amt}, 0) + NVL({custcol_css_grant2_amt}, 0) + NVL({custcol_css_grant3_amt}, 0) 
>= {amount}-1 AND {amount} > 0) 
THEN 'Completely Assigned' 
WHEN  
((NVL({custcol_css_grant1_amt}, 0) + NVL({custcol_css_grant2_amt}, 0) + NVL({custcol_css_grant3_amt}, 0) < {amount})  AND (NVL({custcol_css_grant1_amt}, 0) + NVL({custcol_css_grant2_amt}, 0) + NVL({custcol_css_grant3_amt}, 0)) > 0) 
THEN 'Partially Assigned' 
else 'Unassigned' END
b
Sure. We have one where the foreign amount field is PHP 22.12 and the amount field is 0.42. The custcol_css_grant1_amt field is also 0.42 and so it should be "completely assigned" but shows as "partially assigned." I'm assuming it's an exchange rate issue - or I guess maybe it's a rounding issue - but I don't know how to change that formula to take the rounding into account.
k
Also - double check that your custom columns are numeric or currency. If they are set up as text, they could "look" right, but not calculate properly
oh... exchange rate fun...
You might try using the amount foreign currency field instead of the amount field
{fxamount}
b
This tool was created to be able to only take the amount field in those custom fields. So it has to compare to that. Can you tell a formula to just round to 2 places? Is that something that is possible?
k
yeah. round({fields},decimal places)
though you may want to use cieling instead
https://docs.oracle.com/javadb/10.8.3.0/ref/rreffuncceil.html - just beware - you'll need to do some kind of multiplicaiton by 100, then a division by 100 to get the numbers to "round" correctly with that
b
I'll give these a shot. Thank you SO much for your help!!
Rounding the amount field worked! Thank you!!!