Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
riyazasma1009
Creator
Creator

Help in understanding FindOneOf() function

Hi All,

I was going through the FindOneOf() Function in Qlikview.

As per the Qlikview Help section, it explains FindOneOf() as below:

FindOneOf(text , characterset [ , n])

Returns the position of the n:th occurrence in the string text of any of the characters found in the string characterset. If n is omitted, the position of the first occurrence is returned. If there no matching string is found, 0 is returned.

Example:

findoneof( 'my example text string', 'et%s') returns '4'

findoneof( 'my example text string', 'et%s', 3) returns '12'

findoneof( 'my example text string', '¤%&') returns '0'.

I was able to understand how the output is returned as 4,12 and 0 in the examples  mentioned above. But I am unable to understand as to why "%" is used in every characterset e.g.'et%s'. Even if % is removed, the output turns out to be the same.

Can anyone please explain the use of %?

Thanks,

Asma

2 Replies
Anonymous
Not applicable

Hi Asma Riyaz,

I think they have added the '%' only to show that this function will evaluate any char and it doesn't matter if it's in the evaluated string or not, it always will return a result.

Regards,

-- Karla

tamilarasu
Champion
Champion

Hi,

The below explanation is what I have understood.

From Help: Returns the position of the n:th occurrence in the string text of any of the characters found in the string character set.

findoneof( 'my example text string', 'et%s') returns '4'


In the above example character "e" is found in 4 th position. If you specify the 3 rd parameter ("n") then QV starts search from that position. If no "e" found in the string, then next character will be considered. (QV starts search from the next characterset. i.e "t").


findoneof( 'my 1xampl1 t1xt string', 'et%s') returns '12'


Character "e" is not available in the above example. So it starts looking for second characterset i.e "t".


findoneof( 'my 1xampl1 21x2 s2ring', 'et%s') returns '17'


In the above example, characters e, t and % not available, so it starts looking for the character "s".


findoneof( 'my %xampl1 21x2 s2ring', 'et%s') returns '4'.

In the last case, % is located in 4 th position. Even if the character "s" is available, QV first finds the third specified character i.e "%".

in simple words, If the first character is not found, it automatically searches in the second, third and so on till it finds the exact search that matches our search and it will return the position. If nothing is found it shows of "0"