If you are unable to create a new account, please email support@bspsoftware.com

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

TI Process - Correct code for IF Statement for checking nulls

Started by adnantage, 01 Jul 2014 01:13:55 PM

Previous topic - Next topic

adnantage

We have LastName, MiddleName and FirstName columns in our data source                         
                                                                       
in TI (variable > formula) I mentioned this to combine them as an attribute of variable vProviderNameOnly.
       
vProviderNameOnly=Telcor_Provider_LastName|', '|Telcor_Provider_MI|','|Telcor_Provider_FirstName;     

                   
                                                                       
For names with all three names, it works fine but with no first name or no MI it just throws comma because we mentioned it in the formula.
                                                                             
I was thinking the simplest way would be to first check all 3 variables for null/empty and set them accordingly with or without commas as part of the variable name then set vProviderNameOnly from those values.


if Telcor_Provider_FirstName <> "" then Telcor_Provider_FirstName = ','|Telcor_Provider_FirstName;

if Telcor_Provider_MI <> "" then Telcor_Provider_MI = ','|Telcor_Provider_MI; 



Now  MI and FIrstName are set correclty whether they are empty or not.

vProviderNameOnly=Telcor_Provider_LastName|Telcor_Provider_MI|Telcor_Provider_FirstName;


I just wrote a pseudo code, not a TI code . Can some one please help with the correct coding.



dusherwo

You were pretty close:

if(Telcor_Provider_FirstName @<> "");
  Telcor_Provider_FirstName = ',' | Telcor_Provider_FirstName;
  endif;
if(Telcor_Provider_MI @<> "" );
  Telcor_Provider_MI = ',' | Telcor_Provider_MI;
  endif;

vProviderNameOnly=Telcor_Provider_LastName|Telcor_Provider_MI|Telcor_Provider_FirstName;