Qlik Community

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

double7671
Contributor

how to resue expression

Something like Sum( Sales ) / Count( distinct MonthID & '|' & CustomerID ) is hard to read when analystics calculation gets complicated.

I am thinking to save this expression somewhere with a name "avg sales", then reuse it by invoking the name "avg sales" where I need?

Does Qlikview support and how if yes. Thanks.

Tags (1)
1 Solution

Accepted Solutions
MVP
MVP

Re: how to resue expression

Yes - you can put the expression in a variable and in the place of the expression in your Sheet Object you can use $-sign expansion to evaluate the contents of the variable so it calculates the expression contained in the variable.

The variable can be declared in your load script or via the user interface menu: Settings/Variables Overview/Add or the menu: Settings / Document Properties / Variables Tab / New.

Something like:

    avg_sales = 'Sum( Sales ) / Count( distinct MonthID & '|' & CustomerID )'

And then use this variable like this:

    $(avg_sales)

In various places in Sheet Objects that allow expressions.

2 Replies
MVP
MVP

Re: how to resue expression

you can use variables (ctrl+ alt + v) to store expression

and reuse in different charts

MVP
MVP

Re: how to resue expression

Yes - you can put the expression in a variable and in the place of the expression in your Sheet Object you can use $-sign expansion to evaluate the contents of the variable so it calculates the expression contained in the variable.

The variable can be declared in your load script or via the user interface menu: Settings/Variables Overview/Add or the menu: Settings / Document Properties / Variables Tab / New.

Something like:

    avg_sales = 'Sum( Sales ) / Count( distinct MonthID & '|' & CustomerID )'

And then use this variable like this:

    $(avg_sales)

In various places in Sheet Objects that allow expressions.

Community Browser