Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
guillaume_gorli
Creator II
Creator II

IF "starting by" then ... in script

Hi Everyone,

Can anymone help to write a IF statement based on a criteria "starting by" in the script ?

I have a list of invoices in a database.

Each invoice refrence is starting by a key that is linked to a company.

For instance

Invoices starting by 71 is linked to company A

Invoices starting by 72 is linked to company B

Invoices starting by 73 is linked to company C


I am trying to create a variable "company" using below formulas in my script :

LOAD*,

if ([Nr facture] like 71*,'A',

if ([Nr facture] like 72*,'B',

if ([Nr facture] like 73*,'C'))) as Company;


But i got a message error.


Thanks in advance


Guillaume

4 Replies
sunny_talwar

Try adding single quotes around the search string

if ([Nr facture] like '71*','A',

if ([Nr facture] like '72*','B',

if ([Nr facture] like '73*','C'))) as Company;

Anil_Babu_Samineni

May be this?

if (WildMatch([Nr facture]), '71*','A',

if (WildMatch([Nr facture]), '72*','B',

if (WildMatch([Nr facture], '73*','C'))) as Company;

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
guillaume_gorli
Creator II
Creator II
Author

Of course

Thanks Sunny

sunny_talwar

Anil you missed the closing parenthesis for the WildMatch function

if (WildMatch([Nr facture]), '71*'),'A',

if (WildMatch([Nr facture]), '72*'),'B',

if (WildMatch([Nr facture], '73*'),'C'))) as Company;