Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
Attend QlikWorld 2020 and hear keynote speaker, Malcolm Gladwell. Register by February 29th to save $200. Learn More
Highlighted
Not applicable

LIKE in Conditional IF?

Hello!

I'm trying to do the following in Script:

  • IF:

FLAG_ANOMALY=1

DESCRIPTION LIKE 'SECURITY*'

     Then the value would be No Anomaly for FLAG_DESCRIPTION

  • IF:

FLAG_ANOMALY=1

DESCRIPTION (Other thing than SECURITY*)

     The the value would be With Anomaly for FLAG_DESCRIPTION

  • IF:

FLAG_ANOMALY=0

FLAG_DATE=1

     The the value would be No Anomaly for FLAG_DESCRIPTION

How could I do this? Especially with the "Like".

Thank you!!!

5 Replies
Highlighted
MVP & Luminary
MVP & Luminary

Re: LIKE in Conditional IF?

Hi Mart,

you can use Match() function..

- Ralf

Vizlib Head of R&D
Highlighted

Re: LIKE in Conditional IF?

Try this

IF((FLAG_ANOMALY=1 and wildmatch(DESCRIPTION,'SECURITY*') > 0) or (FLAG_ANOMALY=0 and FLAG_DATE=1) , 'No Anomaly',

     IF(FLAG_ANOMALY=1 and wildmatch(DESCRIPTION, 'SECURITY*') = 0, 'With Anomaly',

'Undefined'

     )

)

let me know ....

Highlighted
anbu1984
Honored Contributor III

Re: LIKE in Conditional IF?

IF(FLAG_ANOMALY=1, If(DESCRIPTION LIKE 'SECURITY*','No Anomaly', 'With Anomaly'),

IF(FLAG_ANOMALY=0 And FLAG_DATE=1,'No Anomaly')) As FLAG_DESCRIPTION

Highlighted
sarvjeet
New Contributor III

Re: LIKE in Conditional IF?

There are many ways to implement the solution :

First of all use case satemant instead of multiple IFs

For LIKE  operator qlik provided below functions:

match( str, expr1 [ , expr2,...exprN ] )

The match function performs a case sensitive comparison.

Example:

match( M, 'Jan','Feb','Mar')

returns 2 if M = Feb

returns 0 if M = Apr or jan

mixmatch( str, expr1 [ , expr2,...exprN ] )

The mixmatch function performs a case insensitive comparison.

Example:

mixmatch( M, 'Jan','Feb','Mar')

returns 1 if M = jan

wildmatch( str, expr1 [ , expr2,...exprN ] )

The wildmatch function performs a case insensitive comparison and permits the use of wildcard characters ( * and ?) in the comparison strings.

Example:

wildmatch( M, 'ja*','fe?','mar')

returns 1 if M = January

returns 2 if M = fex

Highlighted
MVP & Luminary
MVP & Luminary

Re: LIKE in Conditional IF?

..or, if FLAG_ANOMALY can only be 0 or 1:

if(FLAG_ANOMALY=1,

  if(wildmatch(DESCRIPTION,'SECURITY*') > 0, 'No Anomaly', 'With Anomaly'),

  if(FLAG_DATE=1, 'No Anomaly', 'Undefined')) as FLAG_DESCRIPTION

Vizlib Head of R&D