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

How to add a calculated field?

hi there,

load script as following:

SQL select

month,

region,

country,

reason_code,

.....

from....

i want to add a calculated field named 'buyback' base on reason_code, logic is left(isnull(reason_code),'aaa',3)='New'

thank you in advance!

2 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

Not sure if I have understood your definition of buyback correctly - try something like:

LOAD *,

  If(Left(reason_code, 3)='New', 1, 0) As buyback

;

SQL select

month,

region,

country,

reason_code,

.....

from....

(If reason code is null or not equal to New, buyback will be 0)

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

Hi Jonathan,

Thank you for your help.

there are some error message.

SQL##f - Sqlstate:37000, errorcode:156, errormsg:[microsoft][odbc sql server driver][sqo server]incorrect syntax near the keyword 'if'.