COGNOiSe.com - The IBM Cognos Community

Planning & Consolidation => TM1 => Topic started by: adnantage on 01 Jul 2014 01:13:55 PM

Title: TI Process - Correct code for IF Statement for checking nulls
Post by: adnantage on 01 Jul 2014 01:13:55 PM
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.


Title: Re: TI Process - Correct code for IF Statement for checking nulls
Post by: dusherwo on 01 Jul 2014 05:06:46 PM
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;