Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
hugmarcel
Specialist
Specialist

How to translate table fields to variables?

Hi

having table:

thetable:

load * inline [

field, formula

a, sum(1)

b, sum(2)

c, sum(3)

];

How can I automaticaly define variables $(a) = sum(1), $(b) = sum(2), $(c) = sum(3) out of thetable in script?

E.g. translate thetable into script statements:

let a = sum(1);

let b = sum(2);

let c = sum(3);

Thx - Marcel

1 Solution

Accepted Solutions
forte
Partner - Creator
Partner - Creator

Hi Hugmarcel :

Just try this :

test:

load * inline [

field, formula

a, sum(1)

b, sum(2)

c, sum(3)

];

for i = 1 to NoOfRows('test')

          let VariableName = FieldValue('field',$(i));

          let Formula = Lookup('formula','field','$(VariableName)','Test');

 

          let $(VariableName) = '$(Formula)';

 

next

Hope that ir helps.

Best Regards

View solution in original post

2 Replies
forte
Partner - Creator
Partner - Creator

Hi Hugmarcel :

Just try this :

test:

load * inline [

field, formula

a, sum(1)

b, sum(2)

c, sum(3)

];

for i = 1 to NoOfRows('test')

          let VariableName = FieldValue('field',$(i));

          let Formula = Lookup('formula','field','$(VariableName)','Test');

 

          let $(VariableName) = '$(Formula)';

 

next

Hope that ir helps.

Best Regards

hugmarcel
Specialist
Specialist
Author

ok thx, thats working.

However, I was hoping that I could store the variable definitions into a txt file in the script, and then include back the txt file.

But that's not that easy, because of the header of the (txt) file.

Marcel