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

Announcements
Posting on Qlik Community is temporarily paused for some users. Thank you for patience and we'll update you soon!
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

Labels (1)
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