Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
eruditio
Contributor III

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

Re: QV not reading the correct field value due to similar values

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

8 Replies
Not applicable

Re: QV not reading the correct field value due to similar values

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

eruditio
Contributor III

Re: QV not reading the correct field value due to similar values

I am testing as I write.

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

nilesh_gangurde
Valued Contributor

Re: QV not reading the correct field value due to similar values

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

eruditio
Contributor III

Re: QV not reading the correct field value due to similar values

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

Not applicable

Re: QV not reading the correct field value due to similar values

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

QV_question.jpg

eruditio
Contributor III

Re: QV not reading the correct field value due to similar values

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

vamshi_1957
Contributor II

Re: QV not reading the correct field value due to similar values

Try this

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

LET j = NoOfRows('T1');

FOR i = 1 to $(j)

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

NEXT;

eruditio
Contributor III

Re: QV not reading the correct field value due to similar values

That's a smart routine.

I learned a lot today

Thanks to both of you


Antoine

Community Browser