Focal Point
Maximum Number of IF THEN ELSE Pairs?

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

January 23, 2008, 10:48 AM
Tewy
Maximum Number of IF THEN ELSE Pairs?
Can anyone tell me what the maximum number of IF THEN ELSE pairs in a defined field is?

A search in the technical documentation library for 7.6.x release indicates it is still 16, but I have used more than that with no problems.

I have hit the limit (found when the code errored) but although I could try to find the actual limit by removing lines one by one, I was hoping someone here would know.

BTW it's not possible for me to use a DECODE in this instance.

Thanks


WF 7.6.11
Output: HTML, PDF, Excel
January 23, 2008, 11:24 AM
Leah
To my knowledge that hasn't changed. Are you using it in a define or a compute? I've had to play games with defines to get it to work for me. Don't have the example in my mind though.


Leah
January 23, 2008, 11:33 AM
susannah
you can get around that limit, you probably figured that out already.
NEWFIELD/A..=IF.....
ELSE 'XXXX';
NEWFIELD/A...=IF NEWFIELD NE 'XXX' THEN NEWFIELD ELSE
IF ...
ELSE 'XXXX';
...repeat the 2nd bit, redefining the same field name. And when your fex references the fieldname, focus always grabs the last defined one. handy trick.




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
January 23, 2008, 11:37 AM
hammo1j
2 choices -

either rewrite your IF THEN ELSE expression as nested ifs if it is possible to divide the conditions equally or.

-or to retain the same if then else if logic which works like a filter since the tests in each if may not be mutually exclusive

-* needed expression too big with 100 max is 25 say
val = if expr1 then result1
else if expr2 then result2
...
else if expr100 then result100
else resultdefault ;

-* becomes
valgroup1/i2 = if expr1 then 1
else if expr2 then 1
...
else if expr24 then 1
else 0 ;

val1 = if expr1 then result1
else if expr2 then result2
...
else if expr24 then result24
else 0 ;

valgroup2/i2 = if valgroup1 eq 1 then 1
else if expr25 then 2
else if expr26 then 2
...
else if expr48 then 2
else 0 ;

val2 = if valgroup1 eq 1 then val1
else if expr25 then result25
else if expr26 then result26
...
else if expr48 then result48
else 0 ;

and so on...

Try it and you will soon get the idea



Server: WF 7.6.2 ( BID/Rcaster) Platform: W2003Server/IIS6/Tomcat/SQL Server repository Adapters: SQL Server 2000/Oracle 9.2
Desktop: Dev Studio 765/XP/Office 2003 Applications: IFS/Jobscope/Maximo
January 23, 2008, 11:39 AM
hammo1j
Suzannah's method is better and simpler if you can define an else that is not in the possible values so use that!



Server: WF 7.6.2 ( BID/Rcaster) Platform: W2003Server/IIS6/Tomcat/SQL Server repository Adapters: SQL Server 2000/Oracle 9.2
Desktop: Dev Studio 765/XP/Office 2003 Applications: IFS/Jobscope/Maximo
January 24, 2008, 04:23 AM
Tewy
Thanks for the replies, I already have it set up in the way Susannah suggests, so it is working.

It was just before the code came up with the this is too long error, I had it working with at least 40 IF THEN ELSE statements!

After reading the documentation, I have split it up so there's only 16 per defined field now, and it works fine, I was just wondering if anyone else had more insight into this.

Thanks Again


WF 7.6.11
Output: HTML, PDF, Excel
January 24, 2008, 05:05 AM
GamP
I seem to remember that it was not the amount of if-then-else's but more a matter of how much memory it occupies. There is a certain amount of memory reserved for computational elements, and it goes per element. But I can't really remember how much memory that is.
Anyway, the problem is solved easily enough by splitting up, so you don't hit this memory limit any more.


GamP

- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988