Skip to Content
0

Issues with SWITCH function vs. If-Then-Else Statements

Sep 15, 2017 at 10:20 PM

31

avatar image
Former Member

To The Community:

I am currently developing a CR2008 report that uses the following formula:

Switch  (
        {PLANSTAT.SSNPRINTOPTCD} = "0", {EELOAN.SSNUM} [1 to 3] + "-" + {EELOAN.SSNUM} [4 to 5] + "-" + {EELOAN.SSNUM} [6 to 9],
        {PLANSTAT.SSNPRINTOPTCD} = "1", "***-**-" + {EELOAN.SSNUM} [6 to 9],
        {PLANSTAT.SSNPRINTOPTCD} = "2", "",
        {PLANSTAT.SSNPRINTOPTCD} = "3", {JOB.EENUM} [1 to 3] + "-" + {JOB.EENUM} [4 to 5] + "-" + {JOB.EENUM} [6 to 9]
        );

The above formula statement randomly produces blank SSNs all through the 40+ page report, sometimes a single SSN, other times groups of them but seemingly never in a pattern...even though I have verified the {PLANSTAT.SSNPRINTOPTCD} = "1".

I can then replace the above formula with the following original which utilized If-Then-Else statements...which causes the formula and the report to work perfectly! Question: Are they not the same statement especially the fact the SWITCH formula works for the most part but only randomly and the original works correctly? Does it have something to do with the single- or double-quotation marks for string values?

Thanks in advance for the assistance!

James

The original formula as follows:

If {PLANSTAT.SSNPRINTOPTCD}='0' then {EELOAN.SSNUM} [1 to 3 ]+"-"+{EELOAN.SSNUM}  [ 4 to 5 ]+"-"+{EELOAN.SSNUM} [6 to 9 ] else
If {PLANSTAT.SSNPRINTOPTCD}='1' then '***-**-'+{EELOAN.SSNUM} [6 to 9 ] else
If {PLANSTAT.SSNPRINTOPTCD}='2' then '' else
If {PLANSTAT.SSNPRINTOPTCD}='3' then {JOB.EENUM} [1 to 3 ]+"-"+{JOB.EENUM}  [ 4 to 5 ]+"-"+{JOB.EENUM} [6 to 9 ] 
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers