Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Does Qlikview have an equivalent of VB's SUB

Sorry, I'm reasonably new to Qlikview, this is probably a very common question.....

I have inherited a dashboard which has to load in data from about 12 files where the format is identical.

There are 12 large LOAD constructs, where the only difference is the filename of the file they import from and a value inserted into one of the columns.

If I was doing this in VBA, I'd create a SUB item to do this which would take in 2 parameters, one being the filename, the other being the value to put into the "Source Table" column.

Instead, the Qlikview script is much longer, having the same code 12 times.

Is there a way to introduce a SUB into Qlikview?

I asked this question in a training session recently, but I didn't formulate it very well and didn't understand the answer.

Thanks

Steve

1 Solution

Accepted Solutions
flipside
Partner - Specialist II
Partner - Specialist II

You can define subroutines in the Qlikview load script and call them using, well, the CALL command.

Have a look at the QV help menu for CALL.

flipside

View solution in original post

4 Replies
Not applicable
Author

You can use a loop like this:

for each FILENAME in filelist ('.\Transactions_Month_*.xlsx')

  Transactions:

   LOAD *

  FROM [$(FILENAME)] (ooxml, embedded labels, table is [Sheet1]);

next FILENAME;

Not applicable
Author

Many thanks Lucianmultibase, this gives me a pretty good way of approaching the problem in this instance. Ideally, I'd have liked to provide a second parameter for the associated value I could put into the column Source_Table to specift which file a particular row comes from, but I can simply use $(FILENAME) and apply a map later if need be.

Cheers

Steve

flipside
Partner - Specialist II
Partner - Specialist II

You can define subroutines in the Qlikview load script and call them using, well, the CALL command.

Have a look at the QV help menu for CALL.

flipside

Not applicable
Author

Thanks for that flipside - I've found it in the manual and it looks like the way to go.

Steve