Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
Qlik Analytics Tour 2020 Online. Begins August 10th. Register Today
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Creator
Creator

'For Each' to load xls multiple files, a few columns does not have the same name

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) ?

Tags (1)
5 Replies
Highlighted
Master II
Master II

Re: 'For Each' to load xls multiple files, a few columns does not have the same name

Are the columns in the same order, with just the column names different?

Highlighted
Creator
Creator

Re: 'For Each' to load xls multiple files, a few columns does not have the same name

I would avoid load *, as I don't load some of the columns (that exit or not) on different xls.

Highlighted
Master III
Master III

Re: 'For Each' to load xls multiple files, a few columns does not have the same name

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.


https://help.qlik.com/en-US/sense/February2018/Subsystems/Hub/Content/Scripting/ErrorVariables/Scrip...

Highlighted
MVP & Luminary
MVP & Luminary

Re: 'For Each' to load xls multiple files, a few columns does not have the same name

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

Highlighted
Creator
Creator

Re: 'For Each' to load xls multiple files, a few columns does not have the same name

Thanks a lot, I finally managed to get the excel column name corrected.