Discussion board where members can learn more about Qlik Sense App Development and Usage.
Is it possible to do a double loop in qlik? one inside the other?
yes it is possible
Foe Ex;
For i = 0 to 10
For j = 0 to 5
Some code
Next
Next
You are talking about e.g. a FOR ... NEXT loop in the script?
An example for a nested loop can be found here:
yes it is possible
Foe Ex;
For i = 0 to 10
For j = 0 to 5
Some code
Next
Next
I'm trying to do the loop to get the name of tabs in a sheet so I can load all of the tabs in an excel sheet and the way the titles for the tabs are set up is 'MMM-YYYY'
Ok, so how does your current code look like? Do you also have a sample Excel file to work with?
Sheet names are in this formats MMM-YYYY is so it comes same name when you apply loop on the sheets.
Set ErrorMode = 0;
NoConcatenate
TableName:
Load
*
From x
(ooxml, embedded labels, table is Current)
Where Num(MonthYear)<>Null();
NoConcatenate
MaxMonthYear:
Load
Max(Date) As TNMaxMY
Resident TableName;
Let vTNMaxMY=Peek('TNMaxMY');
Let vTNMaxMon=Num(Month($(vTNMaxMY)));
Let vTNMaxYear=Num(Year($(vTNMaxMY)));
Let vTNMonPrev=$(vTNMaxMon)-1;
// First for loop
For Year=Start Year to $(vTNMaxYear);
Let vYear=$(Year);
//For Loop
For num=1 to 12
Let vMY=Date(MakeDate($(vYear),$(num)),'MMM-YYYY');
Concatenate(TableName)
Load
*
From x
(ooxml, embedded labels, table is [$(vMY)])
Where Num(MonthYear)<>Null();
Next
Next
Drop Table MaxMonthYear;
If ScriptErrorCount > 0 then
End IF;
// ErrorMode set back to 1
Set ErrorMode = 1;
// Load DataRefresh.QVD to have previously loaded data and used Exit Script as part of error handling
Concatenate(TableName)
Load
*
From x(qvd)
Where [TableName]='TableName' and Not Exists(Key);
This ended up to be the code that worked for me to get all the tabs in the excel file for whatever year and month and to be able to have missing months.
"This ended up to be the code that worked for me to get all the tabs in the excel file for whatever year and month and to be able to have missing months."
Hm, so there is no open issue? Then please close the thread by selecting 'assumed answered'.
There was this thread helped I will close it
Great, thank you!