Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Return Position of an Element from a List

Hi Everyone,

I am attempting to the find the position of a string within a list but can't get the expression right.

I have a combination of unique strings stored in a field called "list". I have another field called "version" which contains a single element from "list". I'd like to find the position of "version" within "list". 

Here's how I have it set up:

list = '10.0.1', '10.0.2', '10.0.3', '10.0.4'....

version = '10.0.2'

In this example I want an expression to return 2. I've tried using index() and other string functions but I can't quite get it right.

Thanks!

Michael

5 Replies
trdandamudi
Master II
Master II

Please take a look at the attached link and you will be able to find the solution:

Re: Using a comma-separated list of values in Pick() function

Hope this helps...

santiago_respane
Specialist
Specialist

Hi Michael,

if you want to use index you have to consider:

-the length of the item

-Also it must be a string, not a list.

-As index returns the position in the whole string, it must be divided by the length of the item (in this case 6) and also rounded up with the ceil function

=CEIL(INDEX('10.0.1,10.0.2,10.0.3,10.0.4,10.0.5,10.0.6','10.0.4')/6)

Using a list you can go with the match function, it will give you the position of the item to be found, like this:

=Match('10.0.3','10.0.1','10.0.2','10.0.3','10.0.4')

Hope this helps.

Kind regards,

Anonymous
Not applicable
Author

Thanks for the responses so far but I still cannot make it work.

I'd like to stay away from using index() because the denominator does not have a constant length.

Match() returns a "-" for every value in my chart. I've attached a sample qvw.

Any thoughts about where I'm going wrong?

Thanks again.

shree909
Partner - Specialist II
Partner - Specialist II

Hi can you try this

=Pick(Match(index(ver_list,version),1,13,25,37),1,2,3,4)

trdandamudi
Master II
Master II

May be as attached below: