Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
HOW DO I PUT THIS IN AN IF STATEMENT FOR QLIK SENSE.
Hi @Luben , can be like this?
lOAD
if(
(isnull(ORIGIN_COUNTRY) and match(PORT_COUNTRY,'US','CA') >0) or
match(ORIGIN_COUNTRY,'US','CA') > 0, 'EXPORT',
if(
((isnull(DESTINATION_COUNTRY) and match(DISCHARGE_COUNTRY,'US','CA') >0) and
match(PORT_COUNTRY,'US','CA') = 0) or
(match(DESTINATION_COUNTRY,'US','CA') > 0 and
match(PORT_COUNTRY,'US','CA') = 0), 'IMPORT')) as Direction
RESIDENT A;
Hello @Luben , i just tried to put the logic to get one new field.
For example, the beggining of that logic is :
If ORIGIN_COUNTRY is null, and PORT_COUNTRY is 'US' or 'CA', ....
match(ORIGIN_COUNTRY,'US','CA') > 0
That 'match' function search in the field used as first parameter, the text used un second and more parameters.
If it found something , is going yo give you a value above 0, indicating the position, and if it doesnt find what are you looking for, it gives you 0.
thank you so much for your explanation. I guess the only question i have, is this part of the logic when its not
US or CA part i think it missing in the query. I might be wrong.
Hi @Luben , can be like this?
lOAD
if(
(isnull(ORIGIN_COUNTRY) and match(PORT_COUNTRY,'US','CA') >0) or
match(ORIGIN_COUNTRY,'US','CA') > 0, 'EXPORT',
if(
((isnull(DESTINATION_COUNTRY) and match(DISCHARGE_COUNTRY,'US','CA') >0) and
match(PORT_COUNTRY,'US','CA') = 0) or
(match(DESTINATION_COUNTRY,'US','CA') > 0 and
match(PORT_COUNTRY,'US','CA') = 0), 'IMPORT')) as Direction
RESIDENT A;
thank you so much for your input.
Hello could you please give me a brief explanation on the above if statement so I could understand it properly.
thanks
Hello @Luben , i just tried to put the logic to get one new field.
For example, the beggining of that logic is :
If ORIGIN_COUNTRY is null, and PORT_COUNTRY is 'US' or 'CA', ....
match(ORIGIN_COUNTRY,'US','CA') > 0
That 'match' function search in the field used as first parameter, the text used un second and more parameters.
If it found something , is going yo give you a value above 0, indicating the position, and if it doesnt find what are you looking for, it gives you 0.
thank you so much for your explanation. I guess the only question i have, is this part of the logic when its not
US or CA part i think it missing in the query. I might be wrong.