Qlik Community

QlikView Documents

Documents for QlikView related information.

Qlikview Parameterised Variables

Honored Contributor III

Qlikview Parameterised Variables

The Qlikview Variables are quite cool and they can be used as little functions too. For example, the below variable declaration gives the flexibility to use any simple aggregation functions on any fields in the model combined with, set analysis.

The expression to be declared in the script is as follows

Let vCalculateExpression=’$’&1&'({<$’&’2={“>=$’&'(=Date($’&'(vFromDate),”DD/MM/YYYY”))<=$’&'(=Date($’&'(vToDate),”DD/MM/YYYY”))”}>} $’&’3)’;

Please take a note of the ”..The extra single quote acts as an escape character for the quote you want around the text literals. The parameters are passed as $1,$2,$3..etc.

The variable can be called from the qlikview expression editor as follows.. The flexibility this expression gives is that you could choose any of the fields can be used as filters


$(vCalculateExpression(Sum,[Sale Date],[Sales Value]))


$(vCalculateExpression(Count,[Sale Date],[Sales Value]))


$(vCalculateExpression(Avg,[Sale Date],[Sales Value]))

Although , the above expression might look a bit daunting in the first go, it is a very simple expression. the parsed text will look as follows.Please note that I have deliberately left the set analysis hardcoded in the expression but it can very well be passed as another parameter to the variable.

sum({<[Sale Date]={“>=01/12/2015<=31/12/2016”}>} [Sales Value]).. simple! right?

if you were to write the variable in the UI , you would write it as follows
for a variable X, the value is written as $1({<$2={“>=01/12/2015<=31/12/2016”}>} $3). The variable overview editor might yell at you in all red but it will work.

Qlikview Variable Overview


I have attached sample application to this page,Hope you like it.

New Contributor III

Well done. Thanks for the clear explanation. Much appreciated.

Valued Contributor

Excellent, very useful!

Thanks a lot for sharing!

Valued Contributor III

One more post on this ,

Variables with Parameters

New Contributor III

Good post.  Wouldn't this work with a slightly easier expression --simply $1, $2, $3 (i.e. without encoding each character in single quotes)?

Valued Contributor II

Hi Sasi,

Nice post,

Will this work on Qliksense ?

Not applicable

nice one for learning. much appriciable

Honored Contributor III

It depends on what you want to do with the expression. The quoting is required if you want to define your expressions in the script.I hope it makes sense.

Honored Contributor III

Yes it will work in qlik sense also. the issue is that there is no variable driven calendar in it yet!. please see the attachment above for qlik sense!

Valued Contributor

Thanks for sharing!!!

New Contributor III

Super! Thank you sasiparupudi1 for sharing!

Version history
Revision #:
1 of 1
Last update:
‎09-20-2016 09:49 AM
Updated by: