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

Get the current value of a field in a loop and replace value (script editor)

Hi,

I must evaluate a formel in the script. It works partially...

For example, I don't get any result for the 2 last rows. Anybody knows why ? I suppose it's because of the fieldvalue() function, that has to get the value of the good KZID... but I don't find.

That's why this post has this name. I say that because I did a lot of tests and I think this part is the problem, to get the good current KZID value. So in the FieldValue() function.... but it's a supposition...

Thank you for your help!

question_find_values.JPG

2 Replies
johnw
Champion III
Champion III

I tried applying the attached example's approach to your example, but didn't get it to work, and I'm not sure why.  Still, it's a working example doing almost exactly what you're doing, so it's surely close.  There are a couple other working approaches in the script commented out and one that wasn't working.  The replace() approach was by far the fastest in testing on large data sets, though, so you're on the right track.

whiteline
Master II
Master II

Hi.

Briefly, you've used wrong function, try this:

evaluate(replace(Replace(Replace(Formel,V1,Lookup(text(V1),'ID',RecNo(), 'test')), V2,Lookup(text(V2),'ID',RecNo(), 'test')),V3,Lookup(text(V3),'ID',RecNo(), 'test'))) as Result

And you don't need the loop.

QV stores your data in fields. Imagine it as separate listboxes with field values.

FieldValue function just returns the value by the index in that list.

KZID1 in your case has three values - thats why it works only for three lines.

The right calculation of that lines is just happenstance.

You could use lookup() function as mentioned above.

text() function returns a text representation of field value. It seems that it doesn't work without it.