Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Highlighted
Frank_Fu
New Contributor

Determine whether a word is in a text field

Hi, I'm having an issue finding a word in a text field which looks like below:

'NXP54661 A Finance',

'NAP54661 X Finance',

I needed to create another field to show whether 'X' appears in the text field as a single word rather than a letter of a word. in the two shown above, the first should come as False, while the second should come as True. I tried a couple of string functions, but none gave me desired result. For example Index function will count the first as True which is not what I wanted. any help is much appreciated. Thanks.

2 Replies
Employee
Employee

Re: Determine whether a word is in a text field

You can use 'index' function as below.

index(F1,' X ')

F1 is an item of words, and the second parameter contains spaces before and after X.

If you want to use the presence or absence of X as a condition to create other items, you can write the script as follows.

if(index(F1,' X ')>0,'aaa') as Xfield,

 

trdandamudi
Honored Contributor

Re: Determine whether a word is in a text field

Please see the attached file for the solution. Hope this helps:

String.JPG