Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

sixsigmaguy
New Contributor

Wildcards within an IF statement in a Script

Hi everyone,

I multiple IF statements for data scrubbing purposes.  I've tested one but when I use a wildcard it just doesn't work. It seems to ignore it or it tries to literally search for the asterisk within the field data. I also tried % character for a wildcard. No luck.

If ([Make] = 'Mercedes', 'Mercedes Benz', [Make])

If ([Make] = 'Mercedes*', 'Mercedes Benz', [Make])   (doesn't work)



Tags (3)
10 Replies
Not applicable

Re: Wildcards within an IF statement in a Script

Hi Brian,

Try If(Wildmatch([Make],'Mercedes*')=1,'Mercedes Benz',[Make])

You can read more about Wildmatch function in reference manual or QlikView Help.

BR,

Milosz

alexpanjhc
Valued Contributor

Re: Wildcards within an IF statement in a Script

if (wildmatch([Make] , 'Mercedes*')>0,'Mercedes Benz', [Make])

Re: Wildcards within an IF statement in a Script

Or this:

If(Index(Make, 'Mercedes'), 'Mercedes Benz', Make)

holmlund
New Contributor III

Re: Wildcards within an IF statement in a Script

If(Make like '*Mercedes*', Make)

Re: Wildcards within an IF statement in a Script

If ([Make] like 'Mercedes*', 'Mercedes Benz', [Make])

Re: Wildcards within an IF statement in a Script

Hi,

maybe also helpful:

if condition

regards

Marco

sixsigmaguy
New Contributor

Re: Wildcards within an IF statement in a Script

Thank you very much everyone for the WILDMATCH function and the INDEX. I just looked them up in the reference. Wildmatch says it is case sensitive. Sunny do you know if the same is so for Index?

Re: Wildcards within an IF statement in a Script

I think Index is case sensitive as well. To get around this, you can use Upper() or Lower() functions:

If(Index(Lower(Make), 'mercedes'), 'Mercedes Benz', Make)

Re: Wildcards within an IF statement in a Script

WildMatch() and like both are case insensitive.

wildmatch ‒ QlikView

regards

Marco

Community Browser