Skip to main content

New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
NEW webinar Dec. 7th: 2023 Outlook, A Pivotal Year for Data Integration SIGN ME UP!
cancel
Showing results for 
Search instead for 
Did you mean: 
vincent_bellang
Contributor III
Contributor III

Check a character at a certain position

Greetings,

I have a table like this

Server Name
rect4156ezr

rect9685erz

azed1562aze
deer4567ezz

And i want to filter to get only those who have an e at the 9th position on their name, i tried with index("Server Name" ,'e')=9 but i doesn't work if e is present multiple times.

Thanks for answers!

1 Solution

Accepted Solutions
petter
Partner - Champion III
Partner - Champion III

The Index function will not always work in the way you have been thinking. Mid() function is a better and more efficient approach.

Mid("Server Name",9,1) = 'e')

This will do a direct check of the character at the ninth postion without doing a search. Index like you have used will not match on a server name that have one or more 'e' characters before the ninth position even if the ninth character is an 'e'.

Are you doing this in your load script or in a sheet in a visualization table?

If in the load script it would be:

LOAD

    ....

WHERE

    Mid("Server Name",9,1)='e';

If in a visualization table you do it - depends on which dimensions you have - but making a dimension that only includes the server names that have e in the 9th position would be an option:

=If( Mid("Server Name",9,1)='e', "Server Name")

View solution in original post

2 Replies
petter
Partner - Champion III
Partner - Champion III

The Index function will not always work in the way you have been thinking. Mid() function is a better and more efficient approach.

Mid("Server Name",9,1) = 'e')

This will do a direct check of the character at the ninth postion without doing a search. Index like you have used will not match on a server name that have one or more 'e' characters before the ninth position even if the ninth character is an 'e'.

Are you doing this in your load script or in a sheet in a visualization table?

If in the load script it would be:

LOAD

    ....

WHERE

    Mid("Server Name",9,1)='e';

If in a visualization table you do it - depends on which dimensions you have - but making a dimension that only includes the server names that have e in the 9th position would be an option:

=If( Mid("Server Name",9,1)='e', "Server Name")

vincent_bellang
Contributor III
Contributor III
Author

That did the trick!

Thanks Petter i may not had understanded index() correctly but now i do!