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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

script : add a field based on a condition (if ??)

hello

i have a table like this :

account mnt

600000; 300.00

601001; 308.00

606004; 12000.00

700011; 82000.00

780559 ; 12.00

I would like to add a field in my table based :

-field account everything that begins with 6xxxxx (a field expense)

-field account everything that begins with 7xxxxx (a field product)

to arrive at this

account ; mnt ; expense/product

600000; 300.00 ; expense

601001; 308.00 ; expense

606004; 12000.00 ; expense

700011; 82000.00 ; product

780559 ; 12.00 ; product

thanks for your help

1 Solution

Accepted Solutions
jagannalla
Partner - Specialist III
Partner - Specialist III

Hello,

Use the below code.

Load

          account,

          mnt,

          If(Left(account,1)='6','Expense',If(Left(account,1)='7','Product')) as ExpenseOrProduct

From Table;

Hope it helps you..

View solution in original post

2 Replies
jagannalla
Partner - Specialist III
Partner - Specialist III

Hello,

Use the below code.

Load

          account,

          mnt,

          If(Left(account,1)='6','Expense',If(Left(account,1)='7','Product')) as ExpenseOrProduct

From Table;

Hope it helps you..

Not applicable
Author

thank you for your help