Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello!
I'm trying to do the following in Script:
FLAG_ANOMALY=1
DESCRIPTION LIKE 'SECURITY*'
Then the value would be No Anomaly for FLAG_DESCRIPTION
FLAG_ANOMALY=1
DESCRIPTION (Other thing than SECURITY*)
The the value would be With Anomaly for FLAG_DESCRIPTION
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!!!
Hi Mart,
you can use Match() function..
- Ralf
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 ....
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
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
..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