Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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
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...
;
Hi Gysbert,
Can you give me in expression ?
and secondly invoice type 200 and 201 should be considered only when location is empty
If you don't like the expression I posted please explain what expression you want instead.
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
Well, I think you should fix this in the script, but the expressions works just as well in a chart.
can you provide me both?
If(Match([Invoice type],'100','101','105','107','109','190') or (Match([Invoice type],'200','201') and Len(Trim(Location))=0), -Price, Price)
hi gybert this is not correct..invoice type 200 and 201 should be considered only when location is empty and price should price * -1