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

1 Solution

Accepted Solutions
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

View solution in original post

14 Replies
Gysbert_Wassenaar

Something like this maybe:

LOAD

     [Invoice type],

     Location,

     If(Match([Invoice type],'100','101','105','107','109','190') or (Match([Invoice type],'200','201') and Len(Trim(Location))=0), -Price, Price) as Price

FROM

     ...source...

     ;


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

Hi Gysbert,

Can you give me in expression ?

raadwiptec
Creator II
Creator II
Author

and secondly invoice type 200 and 201 should be considered only when location is empty

Gysbert_Wassenaar

If you don't like the expression I posted please explain what expression you want instead.


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

hi gysbert

Iam looking an expression for the front end and not at the script level.. secondly as said invoice type 200 and 201 should be considered only when location is empty

Gysbert_Wassenaar

Well, I think you should fix this in the script, but the expressions works just as well in a chart.


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

can you provide me both?

Gysbert_Wassenaar

If(Match([Invoice type],'100','101','105','107','109','190') or (Match([Invoice type],'200','201') and Len(Trim(Location))=0), -Price, Price)


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

hi gybert this is not correct..invoice type 200 and 201 should be considered only when location is empty and price should price * -1