Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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
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
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
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
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
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
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
Thanks you both for your feedback both worked for me thanks.
LU
QUICK Question is it possible to have this as a field
Where WildMatch(From, 'GB*', 'AB*') AND Left(To, 2) <> Left(From, 2)
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
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
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