Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Select column based on an if statement - does not work? (excel source)

Hi, I got this statement - that checks part of the filename to decide what column name to use importing from sheet

and save that value into a field with a common name.

However it seems the importer evaluates the existence of BOTH Columns regardless if only one of them is to be used according

to the IF-statement (that does not check column values but the filename to avoid checking for Columns that does not exist)

If(Trim(Left(SubField(FileName(),'Open',2),8)) = 'Changes',[CHG],[INC]) As State,

... the problem is only either one or the other column name exists in each source-file, and import fails on the missing column

even if Iam not actually trying to import it imo.

I thought i could workaround by checking filename and decide what column to import based on that - but it seems I cannot?

18 Replies
sunny_talwar

Tried it with Qlik Sense, seems to be working well Except for the fact that it doesn't really rename the column name in the front end for some reason. Try it out

Not applicable
Author

Try add a file that is not matching "Change" and you will see it fail.- it will still look for the INC field in the CHG excel file - also....

sunny_talwar

I did and it works for me without any errors. I will give it a try one more time

sunny_talwar

Works as I would expect. Try one each time the attached two files. Do not have both of them sitting in the same folder when loading

Not applicable
Author

Now I understand why we dont understand each other 🙂

the problem is just that i want to have these in the same folder at the same time and use the name as a variable to know what columns to load from each file. (in Sense Cloud, there is no folder structure possible)....

sunny_talwar

Atleast now we do. And are you trying to load both of them or just one of them? and if you will only load one of them, then how would you decide which one to load?

Not applicable
Author

I want to load all files matching my path ie. \somefiles*.xls

sunny_talwar

I think that is much simpler that what we have been doing thus far. Here are some references while I play around with our current sample

Loading data from multiple xls-files from folder with subfolder

QlikView Maven: Loading All of the Files from a Folder

Dyanamic load of excel files from folder

Not applicable
Author

Iam Sorry Sunny T, the examples is just addressing import of multiple files, that I got covered already

The thing is my files differs in format - ie. column names differs from file A to file B - but data there should go to same Sense column, I also want to to different things based on if a column is existing in a sheet or or not.

It does not seem to be a a way to check if a column is there or not - that is the exact functionality Iam after.

so far I worked-around this by some macros excelside to clean and format the data, it however adds

a manual step I would like to get rid off.