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: 
Anonymous
Not applicable

QV not reading the correct field value due to similar values

Hello Friends,

I am faced with a nasty bug, that I am unable to solve.

HEre is the scenario:

T1:

LOAD * INLINE [

f1, f2

A,85
B,1
C,4
D,2
E,35
F,11
G,11
H,4
I,27
J,5
K,1
L,5
M,1
N,1

]

;

Now I want to count the field values of each occurence and store in a variable to reuse later on.

LET j = NoOfRows('T1');

       

        FOR i = 1 to $(j)

       

            LET vLines$(i) = FieldValue('f2',$(i));

       

        NEXT;

It is failing to assign values for similar fields.

Any thoughts on the matter?

Thanks,

Antoine

1 Solution

Accepted Solutions
Not applicable
Author

As Field will only hold distinct values, Include the concept of table to the above using Peek function.

LET vLines$(i) = peek('f2',$(i),'T1');

Change the counter to start from 0

View solution in original post

8 Replies
Not applicable
Author

As Field will only hold distinct values, Include the concept of table to the above using Peek function.

LET vLines$(i) = peek('f2',$(i),'T1');

Change the counter to start from 0

Anonymous
Not applicable
Author

I am testing as I write.

Thanks for the lead, I'll let you know in a second.

nilesh_gangurde
Partner - Specialist
Partner - Specialist

Hi,

I think you wanted to store all the values of field in the perticular variable.

this is not possible. you can store only one value into variable at a time.

on the other hand if you wanted to reuse it, load another table in the for loop and create one more table.

hope this will help you.

-Nilesh

Anonymous
Not applicable
Author

No no, I wanted to store them in separate variables (indexed).

Not applicable
Author

Did the above worked? I tested and it is working.

QV_question.jpg

Anonymous
Not applicable
Author

I am running it inside the entire code, since I have a gut feeling that it will force QV to read at the line level.

A few more minutes my friend and I'll update the thread

Anonymous
Not applicable
Author

Try this

SET vf2 = Concat(f2, '|');

LET j = NoOfRows('T1');

FOR i = 1 to $(j)

LET vLines$(i) = subfield($(vf2), '|', $(i));

NEXT;

Anonymous
Not applicable
Author

That's a smart routine.

I learned a lot today

Thanks to both of you


Antoine