Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to write IF statement in load script

Hi experts,

Can anyone help me how to write if statement in load script. I try below script and get error.

If

Currency='USD' then
          Sale*Exchange
     Else Sale

End If as Sale, 

2 Solutions

Accepted Solutions
Sokkorn
Master
Master

Hi Sir,

This script is not correct in QlikView. Now let try:

[Data]:

LOAD

...

If(Currency='USD',Sale*Exchange,Sale)     As [Sale],

...

Regards,

Sokkorn

View solution in original post

Anonymous
Not applicable
Author

6 Replies
Sokkorn
Master
Master

Hi Sir,

This script is not correct in QlikView. Now let try:

[Data]:

LOAD

...

If(Currency='USD',Sale*Exchange,Sale)     As [Sale],

...

Regards,

Sokkorn

Anonymous
Not applicable
Author

Sokkorn, it work!!!. Can you help to explain me on your statement?

Sokkorn
Master
Master

Hi,

If(Condition, then, else)

The three parameters condition, then and else are all expressions. The first one, condition, is interpreted logically. The two other ones, then and else, can be of any type. They should preferably be of the same type. If condition is true, the function returns the value of the expression then. If condition is false, the function returns the value of the expression else.

Example:

If(Amount>= 0,'OK','Alarm')

Regards,

Sokkorn

Not applicable
Author

Load

If(Currency='USD',Sale*Exchange,Sale)     As [Sale]

From Source table....

Anonymous
Not applicable
Author

Thanks bika_2010

Anonymous
Not applicable
Author

Thank you Sokkorn. Very nice