Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Using if within the Load statement

I have a data field [PHONE] that contains phone numbers and e-mails. I need to format the phone # during the load and I was trying to use the following:

LOAD
..

//


if (FindOneOf(PHONE, '@') > 0,
// e-mail

(PHONE as [Main Contact]),

// Phone Number or FAX
('+1 (' & Left(PHONE, 3) & ') ' & Mid(PHONE, 4, 3) & '-' & Right(PHONE, 4) as [Main Contact])),

......


FROM

.....

QV displays the error: "Error in expression: ')' expected" and I am not sure why.

I would appreciate an expert advice.

Regards,

VK

Labels (1)
1 Solution

Accepted Solutions
prieper
Master II
Master II

I think that the last bracket is too much, moreover you do not need to bracket the two IF-condition, thus think that

LOAD
..
// if (FindOneOf(PHONE, '@') > 0,
// e-mail
PHONE as [Main Contact],
// Phone Number or FAX
'+1 (' & Left(PHONE, 3) & ') ' & Mid(PHONE, 4, 3) & '-' & Right(PHONE, 4) as [Main Contact]),
......
FROM .....


Peter

View solution in original post

4 Replies
vgutkovsky
Master II
Master II

Hi, Vladimir.

Does this work?

if (FindOneOf(PHONE, '@') > 0, PHONE, ('+1 (' & Left(PHONE, 3) & ') ' & Mid(PHONE, 4, 3) & '-' & Right(PHONE, 4))) as [Main Contact],


prieper
Master II
Master II

I think that the last bracket is too much, moreover you do not need to bracket the two IF-condition, thus think that

LOAD
..
// if (FindOneOf(PHONE, '@') > 0,
// e-mail
PHONE as [Main Contact],
// Phone Number or FAX
'+1 (' & Left(PHONE, 3) & ') ' & Mid(PHONE, 4, 3) & '-' & Right(PHONE, 4) as [Main Contact]),
......
FROM .....


Peter

Not applicable
Author

Yes, it works. Thank you!

Not applicable
Author

Thank you, Peter.