Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Luben
Creator
Creator

if statement

HOW DO I PUT THIS IN AN IF STATEMENT FOR QLIK SENSE.

Luben_0-1614788373668.jpeg

 

3 Solutions

Accepted Solutions
QFabian
Specialist III
Specialist III

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;

QFabian

View solution in original post

QFabian
Specialist III
Specialist III

Hello @Luben , i just tried to put the logic to get one new field.

  • Following the possible ways from your schema.
  • Putting togheter with 'and' when the logic allows me to create that combination.
  • Using 'or' to add a new way ir posibility.

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.

https://help.qlik.com/en-US/qlikview/April2020/Subsystems/Client/Content/QV_QlikView/Scripting/Condi...

 

 

QFabian

View solution in original post

Luben
Creator
Creator
Author

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.

 

Luben_0-1614864627825.png

 

View solution in original post

5 Replies
QFabian
Specialist III
Specialist III

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;

QFabian
Luben
Creator
Creator
Author

thank you so much for your input.

 

Luben
Creator
Creator
Author

Hello could you please give me a brief explanation on the above if statement so I could understand it properly.

 

thanks

QFabian
Specialist III
Specialist III

Hello @Luben , i just tried to put the logic to get one new field.

  • Following the possible ways from your schema.
  • Putting togheter with 'and' when the logic allows me to create that combination.
  • Using 'or' to add a new way ir posibility.

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.

https://help.qlik.com/en-US/qlikview/April2020/Subsystems/Client/Content/QV_QlikView/Scripting/Condi...

 

 

QFabian
Luben
Creator
Creator
Author

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.

 

Luben_0-1614864627825.png