Discussion board where members can get started with Qlik Sense.
I need to insert a script that loads multiple files.
What I have now is:
'Alex' & "Lead ID" as "ID"
FROM [lib://Sales Funnel/Output\Alex Gerdts\Output_Alex.xlsx]
(ooxml, embedded labels, table is Deliverables);
'Fred' & "Lead ID" as "ID"
FROM [lib://Sales Funnel/Output\Alexandre Cardoso\Output_Fred.xlsx]
I would like to have 2 arrays:
1st with the file names: Output_Alex.xlsx, Output_Fred.xlsx
2nd with the values to load: 'Alex','Fred'
Then I would like to change the above code into something similar to this:
for i=1 to Array1Lenght
Array2 & "Lead ID" as "ID"
Any ideas on how to do this?
Go to Solution.
You can learn more about "For Each Next" in the help here:
For each..next ‒ Qlik Sense
I understand what you want to do, and two FOR statements won't do it. The second is nested in the first, which means you will run the nickname twice for each name, for a total of 4 iterations:
What you want is to run the loop only twice but have both the name and nickname available. You can combine the two as a single string and then separate using the SubField() function.
FOR EACH combinedName IN 'Alex-A', 'Fred-F'
LET name = SubField('$(combinedName)', '-', 1);
LET nickname = SubField('$(combinedName)', '-', 2);
'$(nickname)' & "Lead ID" as "ID"
FROM [lib://Sales Funnel/Output\Alexandre Cardoso\Output$(name).xlsx]
FOR EACH name IN 'Alex', 'Fred'
'$(name)' & "Lead ID" as "ID"
FROM [lib://Sales Funnel/Output\Alexandre Cardoso\Output_$(name).xlsx]
That worked nice!
How do I do in order to have 2 different arrays, such as:
FOR EACH nickname IN 'A','F'