Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
Modernize Your QlikView Deployment webinar, Nov. 3rd. REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Partner
Partner

Parameterised variable as a string

Hello!

I'm trying to create a parameterised variable 'My_Function' and pass it a whole bunch of filters to be used in set analysis.

The problem is that the filters have a comma ',' between them for use in set analysis, and the function treats this as a separator for multiple variables.

Example parameterised variable 'My_Function':

SUM( {<$1> } Quantity)

I would call this function with:

My_Function($(vDateFilter),$(vType))

There would actually be 5+ filters and afew different combinations of them.

Where vDateFilter=   Date = {"<=$(vMaxDate)"}

and vType= [LinkType] = {01}

What QlikView actually does is:

SUM( {<Date = {"<=$(vMaxDate)"}> } Quantity) and this will evaluate ok and produce a value, but the other filters such as vType do not get passed over.

I'd like QlikView todo this

SUM( {<Date = {"<=$(vMaxDate)"}, [LinkType] = {01} > } Quantity)

I have tried adding the comma into a variable called vComma and passing $(vDateFilter)$(vComma)$(vType)

Also tried various combinations of dollar expansion and quotes etc, but just not getting what I'm looking for.

Any suggestions?

1 Solution

Accepted Solutions
Highlighted
MVP & Luminary
MVP & Luminary

If you want to pass five parameters then you have to define five paramaters too:

SUM( {<$1, $2, $3, $4, $5> } Quantity)


talk is cheap, supply exceeds demand

View solution in original post

5 Replies
Highlighted
MVP & Luminary
MVP & Luminary

If you want to pass five parameters then you have to define five paramaters too:

SUM( {<$1, $2, $3, $4, $5> } Quantity)


talk is cheap, supply exceeds demand

View solution in original post

Highlighted
Partner
Partner

Hi,

I thought about that, but sometimes where will be 2 parameters, sometimes 5 or more and i was looking to cover all situations with a single 'variable'.

I can add additional parameters into the function, if they are 'unused' would they effect the calculations?

SUM( {<$1, $2, $3, $4, $5, $6, $7, $8, $9> } Quantity)

but called using

My_Function($(vDateFilter),$(vType))

Highlighted
MVP
MVP

If they are unused they would not affect the calculation (that is what I tested). Hence, perhaps you can go with defining additional parameters.

Highlighted
Partner
Partner

It does look like the unused parameters don't effect the calculation, as they don't effect the selections in the Set Analysis.

So I've gone with the approach of adding extra parameters in case I ever need to use them.

Thanks for the responses!

Highlighted
Contributor III
Contributor III

If you wanted to only use one parameter you'll have to do a lot of escaping of characters.

For instance the following expression:

=Sum({<Dim3={'Z'}, Dim2 = {'d', 'e'}>}Expression1)

Popped into a variable and given a parameter for the set analysis:

Sum({<$1>} Expression1)

The parameter for $1 could be in a variable 'vParamVar' say:

'Dim3={' & chr(39) & 'Z' & chr(39) & '}' & chr(44)  & 'Dim2 = {' & chr(39) & 'd' & chr(39) & chr(44) & chr(39) & 'e' & chr(39) & '}'

Then to call the expression you would need todo the following:

$(='$(Variable1(' & $(=vParamVar) & '))')

Both ways have their merits!