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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
prahlad_infy
Partner - Creator II
Partner - Creator II

Is there any better way to store field value in variable based on another field value at script level ?

Hi All ,

Is there any better way to store field value in variable based on another field value at script level?
I have used below approach .

Wheels:
LOAD * INLINE [

Indicators, Logged_Value
torque percent, 2.3
shear factor, 0.5
error, 0.0005
];
NoConcatenate

temp:
LOAD * ,
RowNo() as sno
Resident Wheels where Match(Indicators,'torque percent');

LET vtorque_percent = Peek('Indicators',0,'temp') ;

DROP Table temp ;

temp:
LOAD * ,
RowNo() as sno
Resident Wheels where Match(Indicators,'shear factor');

LET vshear_factor = Peek('Indicators',0,'temp') ;

DROP Table temp ;

temp:
LOAD * ,
RowNo() as sno
Resident Wheels where Match(Indicators,'error');

LET verror = Peek('Indicators',0,'temp') ;

DROP Table temp ;

DROP Table wheels;

1 Solution

Accepted Solutions
rubenmarin

Hi, a different way to load them can be like:

Wheels:
LOAD * INLINE [
Indicators, Logged_Value
torque percent, 2.3
shear factor, 0.5
error, 0.0005
];

FOR i=0 to NoOfRows('Wheels')
	LET vIndicator = Peek('Indicators',$(i),'Wheels');
	LET varName = 'v'& Replace('$(vIndicator)',' ','_');
	LET $(varName) = Peek('Logged_Value',$(i),'Wheels');
NEXT

DROP Table Wheels;

View solution in original post

1 Reply
rubenmarin

Hi, a different way to load them can be like:

Wheels:
LOAD * INLINE [
Indicators, Logged_Value
torque percent, 2.3
shear factor, 0.5
error, 0.0005
];

FOR i=0 to NoOfRows('Wheels')
	LET vIndicator = Peek('Indicators',$(i),'Wheels');
	LET varName = 'v'& Replace('$(vIndicator)',' ','_');
	LET $(varName) = Peek('Logged_Value',$(i),'Wheels');
NEXT

DROP Table Wheels;