Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
cata_pli
Partner - Contributor III
Partner - Contributor III

Engine error after adding a number to a variable parameter

Hello, 

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:

Error.PNG

Thank you very much for you time !!!

Catalin. 

4 Replies
tresesco
MVP
MVP

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

cata_pli
Partner - Contributor III
Partner - Contributor III
Author

It doesn'work, I get the same error !

Thank you !

marcus_sommer

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

cata_pli
Partner - Contributor III
Partner - Contributor III
Author

Thank you Marcus.

I ended up using two parameters.