Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Frank_Fu
Contributor
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
Yuki_Suzuki
Employee
Employee

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
Master II
Master II

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

String.JPG