Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi everybody,
I load multiple excel files in a For Each loop.
Inside the loop I have a Load from Load then a Left join.
In 2 files one column name is not the one I should get.
Is there a way to test the existence of a column in a Load and when it doesn't exist to load another column (I cannot change the header of the excel files) ?
Are the columns in the same order, with just the column names different?
I would avoid load *, as I don't load some of the columns (that exit or not) on different xls.
One work around could be to use exact column names, and if you want to make decisions at run time, you may allow Qlik to generate error, you can continue script execution through set ErrorMode=0; based on error code returned in script error variable you can write code to read new column etc to handle exception condition.
There is no way within a load to check if a field exists. This meant you need for such a checking an additional step in beforehand - maybe by loading one single record of the file with the wildcard * for the fields and then looping through the exist fieldnames and comparing them against your condition and branching appropriately.
If you know exactly which files are different you could also use a small if-loop on them to branch in different load-statements. Maybe a bit more easier could it be to load your files without labels and name the fields explicitly like:
A as AField,
B as BField,
...
- Marcus
Thanks a lot, I finally managed to get the excel column name corrected.