Published 16 June 2014

Parameter in variables

Parameter in variables

Parameter passing to variables is a very useful capability but unfortunately not very common.

What you do is that you create a place holder for one or several parameters in your variable and when you call the variable you also pass parameter values.

Let’s go on with an example.

Assume we have an application where we want to see the Actuals for external customers in some places and internal customers on others. Does one work with variables we may find variables looking like this

eActualsCustomerExternal = sum({<CustomerType={'External'}>}Actual)

eActualsCustomerInternal= sum({<CustomerType={'Internal'}>}Actual)

eActuals = sum(Actual)

However with the help of parameter passing in variables we can concatenate these two to variable to a single one

eActuals = sum({<CustomerType={'$1'}>} Actual)

In the expression above we have the $1 which is a holder for a parameter to be passed when the variable is being called.

When calling the variable we write

eActuals(External)

And thus ‘External’ is the paramater replacing the $1 in the variable expression.

Passing more parameters can be done by separating the parameters with a comma

eActuals(External, CustomerType)

 

But remember to create a placeholder for each parameter

eActuals = sum({<$2={'$1'}>} Actual)

Parameter passing to variables is a very useful capability but unfortunately not very common.

What you do is that you create a place holder for one or several parameters in your variable and when you call the variable you also pass parameter values.

Let’s go on with an example.

Assume we have an application where we want to see the Actuals for external customers in some places and internal customers on others. Does one work with variables we may find variables looking like this

eActualsCustomerExternal = sum({<CustomerType={'External'}>}Actual)

eActualsCustomerInternal= sum({<CustomerType={'Internal'}>}Actual)

eActuals = sum(Actual)

However with the help of parameter passing in variables we can concatenate these two to variable to a single one

eActuals = sum({<CustomerType={'$1'}>} Actual)

In the expression above we have the $1 which is a holder for a parameter to be passed when the variable is being called.

When calling the variable we write

eActuals(External)

And thus ‘External’ is the paramater replacing the $1 in the variable expression.

Passing more parameters can be done by separating the parameters with a comma

eActuals(External, CustomerType)

 

But remember to create a placeholder for each parameter

eActuals = sum({<$2={'$1'}>} Actual)