Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Connect 2026 Agenda Now Available: Explore Sessions
cancel
Showing results for 
Search instead for 
Did you mean: 
alec1982
Specialist II
Specialist II

Subroutine

hi,

trying to get subroutine called to use variable value.. the variables is set from a column using for. but getting errors.. any idea?

ListOfFiles:

Load * inline [

Files

ABC

ASD

AQW 

AQSW 

];

Sub ScanData

let vss = $(vSetofFile) ;

End Sub

Let vNumofFiles = noofrows('ListOfFiles');

For i= 1 to $(vNumofFiles)

Let vSetofFiles = fieldvalue('ListOfFiles',$(i));

Call ScanData

Next;

10 Replies
Anonymous
Not applicable

tresesco
MVP
MVP

I didn't get any error running this script snippet.

jagan
Partner - Champion III
Partner - Champion III

Hi,

Try like this

Sub ScanData (index, SetOfFile)

  If index = 1 THEN

  table2:

  Load * inline [

  SS

  1

  ];

  ENDIF

  

  Concatenate(table2)

  Load '$(SetOfFile)'  as SS

  AutoGenerate (1);

End Sub

ListOfFiles:

Load * inline [

Files

ABC

ASD

AQW 

AQSW 

];

ListOfFiles:

Load * inline [

ListOfFiles

AluminiumPrimia-A

AluminiumPrimia-B

CopperPrimia-A  

CopperPrimia-B  

];

Let vNumofFiles = noofrows('ListOfFiles');

For i= 1 to $(vNumofFiles)

Let vSetofFiles= fieldvalue('ListOfFiles',$(i));

Call ScanData(i, vSetofFiles)

Next;

Hope this helps you

Regards,

Jagan.

PradeepReddy
Specialist II
Specialist II

can you explain, what you are trying to achieve ? What would be your output?

alec1982
Specialist II
Specialist II
Author

thank you guys,

I made some changes to the question..

it doesnt give an error now but it return null values too if you debug it..

jagan
Partner - Champion III
Partner - Champion III

HI,

Did you tried the script which I posted?  It is working for me.

Regards,

Jagan.

rajeshforqlikvi
Creator
Creator

Hi Please follow be below link:

Code Reusability in QlikView and Debugging QlikView Scripts - YouTube

Regards

Rajesh Kumar

tamilarasu
Champion
Champion

Try,

ListOfFiles:

Load * inline [

Files

ABC

ASD

AQW

AQSW

];

Sub ScanData

let vss = vSetofFiles ;

End Sub

Let vNumofFiles = noofrows('ListOfFiles');

For i= 1 to $(vNumofFiles)

Let vSetofFiles = fieldvalue('Files',$(i));

Call ScanData

Next;

BTW, What is your exact requirement.?

tresesco
MVP
MVP

Which null are you talking about? The one returned by the following statement?

let vss = $(vSetofFile)

If so, it's obvious, because variable vSetofFile is not defined before you use it here. And in the snippet, you don't use vss either. So you can probably remove that line itself. I am not sure if you meant something else.