Calculation / If Statement help needed

More
10 years 7 months ago #6188 by ckelsoe
I have a source field that requires a value. I also want to append the phone extension to that value if it is available. I first wrote the following expression which works sort of...
Code:
BEGIN Iif(Length([F002])> 0,[F001] + ' ext ' + [F002],[F001]) ; END;

I also set the OnError = Set to Value 000-000-0000 however, the calculation fails and all that is written is the 000-000-0000.

I then tried the following which also fails
Code:
BEGIN if(Length([F001]> > 0 Then Result : = Iif(Length([F002])> 0 THEN [F001] + ' ext ' + [F002],[F001]) ; else Result : = '000-000-0000' END;

I also tried the following which also fails:
Code:
if(Length([F002])> 0 THEN BEGIN Result := [F001] + ' ext ' + [F002] END Else BEGIN Result := [F001] END;

How does this need to be written so it works?

Please Log in or Create an account to join the conversation.

More
10 years 7 months ago #6196 by admin
It should be

BEGIN
result:=Iif(Length([F002])> 0,[F001] + ' ext ' + [F002],[F001]) ;
END;

Iif is a function

Mike
ETL Architect

Please Log in or Create an account to join the conversation.