Focal Point
Nested IF THEN ELSE

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/5701048331

March 11, 2005, 02:34 PM
<kj>
Nested IF THEN ELSE
Any one has an Idea how to write Nested IF in webfocus 5.3.2

Some thing like this..

compute x/i1 = if VAR1 <> 'VAL1' then { if VAL2 <100 and VAL2 > 50 then 1 else if VAL2 <= 50 and VAL2 >10 then 2 else if VAL2 <= 10 and VAL2 >1 then 3 ...} else {if VAL2 <500 and VAL2 > 100 then 1 else if VAL2 <= 100 and VAL2 >50 then 2 else if VAL2 <= 50 and VAL2 >5 then 3 ... }

Thanks,
kj
March 11, 2005, 02:42 PM
Leah
compute x2/a1 =
if val ne 5 then 'a' else if val ne 6 then 'b'
else if val is-from 1 to 4 then 'c' else if
val eq 5 or 6 then 'd' .....
;

Basically the same as you have it with the greater than less than and so on replaced with valid FOCUS comparators. Of course the above has a logic flaw in it. as 1 to 4 will be assigned an 'a' based on the first if, so you need to take care how you set it up. Once a true condition is hit, you're done.
March 11, 2005, 02:45 PM
reFOCUSing
Is this what your trying to do:

if VAR1 NE 'VAL1' then
(if ((VAL2 GT 100) and (VAL2 LT 50)) then 1 else
if ((VAL2 GE 50) and (VAL2 LT 10)) then 2 else
if ((VAL2 GE 10) and (VAL2 LT 1)) then 3 else 0) else
if ((VAL2 GT 500) and (VAL2 LT 100)) then 1 else
if ((VAL2 GE 100) and (VAL2 LT 50)) then 2 else
if ((VAL2 GE 50) and (VAL2 LT 5)) then 3 else 0;

This message has been edited. Last edited by: <Mabel>,
March 11, 2005, 02:58 PM
<kj>
Thanks CurtisA. Thats what exactly I am looking for.