Skip to main content
Showing results for 
Search instead for 
Did you mean: 
Partner - Contributor III
Partner - Contributor III

Engine error after adding a number to a variable parameter


I define one variable in variable editor:

a = Sum({< Year=, Month=, MonthCounter={$(=max(MonthCounter)-$1)} >} total Amount)

where MonthCounter is a number counting distinct YearMonths.


I want to create a second variable:

b = $(a($1)) + $(a(1+$1))

The first half works ok, but when I write in editor the second part (1+$1), I get this errors:

 - No available qlik sense engine was found. Refresh your browser.... and I have to wait for a couple of minutes to log in again.

I know I can make variable b with 2 parameters instead, but shouldn't it be possible to add a number to a variable parameter. 

Additional info:

If I define var a as something really simple like : a = 100 +$1, and then define Var b= $(a(100+$1)), I do not get an engine error, but please see what the Variable expansion looks like in the photo bellow:


Thank you very much for you time !!!


4 Replies

Instead of, b = $(a($1)) + $(a(1+$1)),   try b = $(a($1)) + $(a($1+1)). 

Partner - Contributor III
Partner - Contributor III

It doesn'work, I get the same error !

Thank you !


IMO is nesting of variables a bad idea. In general it's possible but there are some restrictions especially to included commas which couldn't be masked and which are always treated as parameter-delimiter. Also the syntax by defining and calling the variables isn't trivial at all. Therefore you adds with such an approach much more complexity as you could get in shorter expressions, readability, performance ... what ever. It's not worth.

Beside this I think your call is wrong because you set there $ but those $ belong to the variable-definition. Personally I would tend to the following:

a = Sum({< Year=, Month=, MonthCounter={$(=max(MonthCounter) - $1 + $2)} >} total Amount)

and then calling the variable with something like:

rangesum($(a(1, 0)), $(a(1, 1)))

- Marcus

Partner - Contributor III
Partner - Contributor III

Thank you Marcus.

I ended up using two parameters.