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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
tamilarasu
Champion
Champion

Store excel data into variables

animated-red-hello-smiley-emoticon.gif

I want to store the below table into variables while loading the file. Can anyone suggest me a load script (loop!!) for this.

Capture.PNG

Output should be loaded as variables like below

Capture.PNG

Thank you.

1 Solution

Accepted Solutions
Ralf-Narfeldt
Employee
Employee

Directory;

Sample:

LOAD Parameter,

     Target,

     Weight

FROM

Sample.xlsx

(ooxml, embedded labels, header is 1 lines, table is Sheet1);

Variables:

Load 'Target.' & Parameter As Variable,

     Target As Value resident Sample;    

Load 'Weight.' & Parameter As Variable,

     Weight As Value resident Sample;

    

For vI = 1 to NoOfRows('Variables')

    Let vVariable_Name = Peek('Variable',vI,'Value');

    Let [$(vVariable_Name)] = Peek('Value',vI,'Value');

Next vI

View solution in original post

6 Replies
mohammadkhatimi
Partner - Specialist
Partner - Specialist

Hie...

What is your exact requirment????

petter
Partner - Champion III
Partner - Champion III

Should looklike this .... I am typingon my phone so it might not be working 100%...

Input:

LOAD

  *

FROM

  Sample.xlsx (....);

FOR row=1 TO NoOfRows('Input')

  Target.$(=Peek('Parameter',row-1)) = Peek('Target',row-1);

  Weight.$(=Peek('Parameter',row-1)) = Peek('Weight',row-1);

NEXT;

DROP TABLE Input;

tamilarasu
Champion
Champion
Author

Hellooo,

It's hard to explain. I need to concatenate the above values with some expressions. I can manage and provide the output by using this method.

Ralf-Narfeldt
Employee
Employee

Directory;

Sample:

LOAD Parameter,

     Target,

     Weight

FROM

Sample.xlsx

(ooxml, embedded labels, header is 1 lines, table is Sheet1);

Variables:

Load 'Target.' & Parameter As Variable,

     Target As Value resident Sample;    

Load 'Weight.' & Parameter As Variable,

     Weight As Value resident Sample;

    

For vI = 1 to NoOfRows('Variables')

    Let vVariable_Name = Peek('Variable',vI,'Value');

    Let [$(vVariable_Name)] = Peek('Value',vI,'Value');

Next vI

tamilarasu
Champion
Champion
Author

Hello Ralf,

Thanks. I have changed the value of vl to 0 (For vI = 0 to NoOfRows('Variables')) and the code is working as expected.

tamilarasu
Champion
Champion
Author

Dear Petter,

I have adopted the code but the parameter names are not fetched correctly. So it's replacing the value again and again. See the below screenshots.

Capture.PNG  Capture2.PNG

I guess we need to adjust the below part.  wondering-smiley-emoticon.png

Target.$(=Peek('Parameter',row-1))

Weight.$(=Peek('Parameter',row-1))