Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

index function

i have following field

Names

ali

hammad

ahmed

in text box i used =Index(NAME,'ALI') this show zero

i want to display the index number of the ali,hammad,ahmed

1 Solution

Accepted Solutions
SunilChauhan
Champion
Champion


this is beacuse ali is first word


Index(NAME,'ali')


for more see this


index(s1 , s2[ , n])

Position of a substring. This function gives the starting position of the n:th occurrence of substring s2 in string s1. If n is omitted, the first occurrence is assumed. If n is negative, the search is made starting from the end of string s1. The result is an integer. The positions in the string are numbered from 1 and up.

Examples:

index( 'abcdefg', 'a' ) returns 0

index( 'abcdefg', 'cd' ) returns 3

index( 'abcdabcd', 'b', 2 ) returns 6

index( 'abcdabcd', 'b', -2 ) returns 2

left( Date, index( Date,'-') -1 ) where Date = 1997-07-14 returns 1997

mid( Date, index( Date, '-', 2 ) -2, 2 ) where Date = 1997-07-14 returns 07

Sunil Chauhan

View solution in original post

4 Replies
SunilChauhan
Champion
Champion


this is beacuse ali is first word


Index(NAME,'ali')


for more see this


index(s1 , s2[ , n])

Position of a substring. This function gives the starting position of the n:th occurrence of substring s2 in string s1. If n is omitted, the first occurrence is assumed. If n is negative, the search is made starting from the end of string s1. The result is an integer. The positions in the string are numbered from 1 and up.

Examples:

index( 'abcdefg', 'a' ) returns 0

index( 'abcdefg', 'cd' ) returns 3

index( 'abcdabcd', 'b', 2 ) returns 6

index( 'abcdabcd', 'b', -2 ) returns 2

left( Date, index( Date,'-') -1 ) where Date = 1997-07-14 returns 1997

mid( Date, index( Date, '-', 2 ) -2, 2 ) where Date = 1997-07-14 returns 07

Sunil Chauhan
its_anandrjs

Hi,

It is case sensitive when use try like this

LOAD * Inline

[

Names

ali hammad ahmed

];

Index(NAME,'ali') //Because you use caps name ALI

Regards,

Anand

Anonymous
Not applicable
Author

HI Hammad

Try this function

=FieldIndex('Name','harsha') if Name as Field and 'Harsha' as text to find

Regards

Harsha

andriesb
Creator II
Creator II

Just a small addition as there is a fault within the result provided.

To test if a given substring exists within a string:

index( 'abcdefg', 'a' ) returns 1    (not 0)

index( 'abcdefg', 'x' ) returns   ('x' does not exist within the string)