Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Dynamic variable value issue

Hi All,

I am having issue with below code,it creates  dynamic variables,but its assigning wrong text from next variable.

Help:

LOAD ChartName,
    
VariableName,
    
Text,
    
Section

FROM
[..\..\Source_Files\Bonus\Help\Text.QVD](
qvd);

LET nRows = NoOfRows('Help')-1;
FOR i = 0 to $(nRows)
let vVariable = FieldValue('VariableName',$(i));
let $(vVariable) = FieldValue('Text',$(i));
NEXT i

Please any help will be appreciated

Thanks

Neetha

1 Solution

Accepted Solutions
Not applicable
Author

What I mean is, in order to do the required loop through, you need a value to use during each iteration of your lookup.

For this you would need a rowno to match against the i variable already created.

or create a concat list of 'VariableName' to for loop over.

Just pointing out you would need a bit of extra coding to use lookup that's all, where as peek could just be substituted in with ease to code already posted.

let vVariable = Peek('VariableName',$(i));
let $(vVariable) = Peek('Text',$(i));

Joe

View solution in original post

15 Replies
giakoum
Partner - Master II
Partner - Master II

most likely you have repeating values between rows

use lookup instead of fieldvalue

giakoum
Partner - Master II
Partner - Master II

Note the Note

FieldValue(fieldname , n )

Returns the field value found in position n of the field fieldname (by load order). fieldname must be given as a string value, e.g. the field name must be enclosed by single quotes. The first field value is returned for n=1. If n is larger than the number of field values, NULL is returned.

Note: This function will only work with distinct field values.

Example:

FieldValue( 'HelpText', 5 )

Anonymous
Not applicable
Author

Hi Ioannis,

all values are distinct in the file.

Thanks

Neetha

giakoum
Partner - Master II
Partner - Master II

maybe in a row level

but not in field level. you have fields that have not unique values

giakoum
Partner - Master II
Partner - Master II

post the file if possible

Anonymous
Not applicable
Author

hi ioannis,

yes you are right section field has duplicates.

its not possible to upload file

Thanks

Neetha

avinashelite

Hi neetha,

Can you please tell what is the requirement ? because for the same variable your assigning two value one with text and one with variable name, so the combination may be unique but not the individual column elements . If that is the case try to build a composite key out of both and while extracting you can divide the composite key and use the variable

giakoum
Partner - Master II
Partner - Master II

then you cannot use FieldValue. you need to use Lookup instead.

Not applicable
Author

can anybody post any example of lookup

thanks