Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Highlighted
cbushey1
Contributor III

Sub routine - passing field names

Hi all,

Hoping for some help on this. 

I have a chunk of code that I am repeating many times in my data model so I thought it would be perfect to move this to a sub routine with some parameters (as each run is slightly different). 

The issue I am having is that when I try to pass the a field name and use it in where clause I am getting '' instead of the field. 

Sub Calc (vMeasure)

TEMP_Table1:
LOAD
 Field1
, Field2
WHERE '$(vMeasure)' = 1

END SUB

CALL CALC (CYFlag);

 

So in this quick example, I would get an error stating that '' =1. 

How can I specify the name of a field that exists in that table as part of the Call?

Labels (1)
1 Solution

Accepted Solutions
Partner
Partner

Re: Sub routine - passing field names

You should try to put ' ' around your parameter value 'CYFLAG'.

See the adjusted script below.

Sub Calc (vMeasure)

TEMP_Table1:
LOAD
 Field1
, Field2
WHERE [$(vMeasure)] = 1

END SUB

CALL CALC ('CYFlag');
???
Celebrating my 300 accepted solution in the Qlik Community
???
2 Replies
Partner
Partner

Re: Sub routine - passing field names

You should try to put ' ' around your parameter value 'CYFLAG'.

See the adjusted script below.

Sub Calc (vMeasure)

TEMP_Table1:
LOAD
 Field1
, Field2
WHERE [$(vMeasure)] = 1

END SUB

CALL CALC ('CYFlag');
???
Celebrating my 300 accepted solution in the Qlik Community
???
cbushey1
Contributor III

Re: Sub routine - passing field names

Thanks. I literally just figured that out and now it is working. 

Thanks for the post though!