Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Luben
Creator
Creator

like and not like

hey am trying to wire below state in the load script 

load 

xyz,

From,

To

From Table_Name

where from Like ‘GB*’ or From Like ‘AB*’ And To Not like ‘GB*’ or ‘AB*’;

 

Does the above like correct any response is welcome 

Thanks

3 Solutions

Accepted Solutions
marcus_sommer

In general you could use like in the same way like in sql but especially if there are multiple items it's easier to use wildmatch() for it, like:

where wildmatch(From, 'GB*', 'AB*') and wildmatch(TO, 'GB*', 'AB*') = 0;

- Marcus

View solution in original post

JuanGerardo
Partner - Specialist
Partner - Specialist

I agree with @marcus_sommer , there are many possibilities in Qlik Sense. And you can use different options here like WildMatch, a mapping table or combine them:

Where WildMatch(From, 'GB*', 'AB*') AND Left(To, 2) <> Left(From, 2)

JG

View solution in original post

marcus_sommer

Yes, it's quite the same like with the above mentioned flag - and instead of 0 or 1 you could return any available field or another manual value, maybe:

load *,
    if(WildMatch(From, 'GB*', 'AB*') AND Left(To, 2) <> Left(From, 2), From, null()) as Export
from x;

If there are multiple conditions on multiple values and/or fields it might be useful to prepare the fields in beforehand with something like left(FIELD, 2) to simplify the check and avoiding like's or wildmatch() and to be able to put the check-values into a mapping and returning the appropriate matchings per applymap().

- Marcus

 

View solution in original post

16 Replies
JuanGerardo
Partner - Specialist
Partner - Specialist

Hi @Luben, I think you have a typo in your expression, and maybe you need parenthesis (but it will depend on your final logic):

load 

xyz,

From,

To

From Table_Name

where (from Like ‘GB*’ or From Like ‘AB*’) And (To Not like ‘GB*’ or or To Not like ‘AB*’);

 

JG

Luben
Creator
Creator
Author

Thanks JG correct i was missing parentheses now i guess my question is could i write Like and Not like same we do in SQL

 

Thanks

marcus_sommer

In general you could use like in the same way like in sql but especially if there are multiple items it's easier to use wildmatch() for it, like:

where wildmatch(From, 'GB*', 'AB*') and wildmatch(TO, 'GB*', 'AB*') = 0;

- Marcus

JuanGerardo
Partner - Specialist
Partner - Specialist

I agree with @marcus_sommer , there are many possibilities in Qlik Sense. And you can use different options here like WildMatch, a mapping table or combine them:

Where WildMatch(From, 'GB*', 'AB*') AND Left(To, 2) <> Left(From, 2)

JG

Luben
Creator
Creator
Author

Thanks you both for your feedback both worked for me thanks.

 

LU

Luben
Creator
Creator
Author

QUICK Question is it possible to have this as a field 

Where WildMatch(From, 'GB*', 'AB*') AND Left(To, 2) <> Left(From, 2)

marcus_sommer

If you mean to use the condition to create a flag then yes, like:

load *,
    if(WildMatch(From, 'GB*', 'AB*') AND Left(To, 2) <> Left(From, 2), 1, 0) as Flag
from x;

- Marcus

Luben
Creator
Creator
Author

Thanks Marcus for the response i was trying to create a field called export, so in other words would create import in reverse of the export field

 

Thanks

marcus_sommer

It's not quite clear to me what do you mean with creating an export- and reversed import-field. The above mentioned  flag-logic returns a boolean value which could be each regarded as the reversed against the other.

- Marcus