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: 
cbushey1
Creator III
Creator 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
Vegar
MVP
MVP

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');

View solution in original post

2 Replies
Vegar
MVP
MVP

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');
cbushey1
Creator III
Creator III
Author

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

Thanks for the post though!