Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
raadwiptec
Creator II
Creator II

expression

i need to write and expression for the following below..

I have the following columns in my source.

Invoice type

Location

Price

i need an expression for the following condition

invoice type should be 100,101,105,107,109,190 plus if location is null --invoice type should be 200 and 201 , then output should be Prices * -1

14 Replies
Gysbert_Wassenaar

Looks correct to me. Point out the error please.


talk is cheap, supply exceeds demand
raadwiptec
Creator II
Creator II
Author

how is this condition getting fulfilled?

invoice type 200 and 201 should be considered only when location is empty and output is price * -1

Gysbert_Wassenaar

Just to make sure we both understand boolean logic the same way perhaps you should Google for "boolean and operator" to find out what an and does between two conditions.


talk is cheap, supply exceeds demand
r3iuk
Creator
Creator

Gysbert's answer is correct according to my interpretation of your requirement.  However it can be tricky sometimes to read complex if statements when they are written on one line so I often break them up into separate lines to check they are constructed in the way that I want them to be.  So Gysbert's statement can be written as:

if(

Match([Invoice type],'100','101','105','107','109','190')

or

(

Match([Invoice type],'200','201')

and

Len(Trim(Location))=0

),

-1,

1

) * Price

You could write a more long winded version which you may or may find more understandable, but I would stick with Gysbert:

if(

Match([Invoice type],'100','101','105','107','109','190'),

-1,

if(

Match([Invoice type],'200','201')

and

Len(Trim(Location))=0,

-1,

1

)

) * Price

raadwiptec
Creator II
Creator II
Author

Hi Mike .Gybs

Indeed both looks same, other than the -1 and the -Price at the end..

thanks both