Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Connect 2026 Agenda Now Available: Explore Sessions
cancel
Showing results for 
Search instead for 
Did you mean: 
DawidDaw
Contributor III
Contributor III

Nested Variables not working - sum of variables only evaluating first variable

Hello,

 

Im developing a QS app in QS Enterprise server. I have multiple variables that are frequently summed. When I use the syntax I am used to it only sums the first part.

Example:

Variables:

vVar1 = 3

vVar2 = 5

Result I am getting (last should obviously be 8):

EXPRESSION used=$(vVar1)=$(vVar2)=$(vVar1)+$(vVar2)
RESULT353

 

If I flip the variables around ($(vVar2)+$(vVar1)) I get 5 as a result.

I tried different syntaxes, all return an error or nothing.

What I tried:

  • adding or removing $ in variables or expression
  • adding or removing = in variables or expression
  • moving around the brackets

Everything return an error or a " - " cell, except the above method which only sums the first one.

 

Any idea's?

 

Thanks!

10 Replies
sunny_talwar

What happens when you use RangeSum()?

RangeSum($(vVar1), $(vVar2))

 

DawidDaw
Contributor III
Contributor III
Author

Hi Sunny,

 

It returns an empty value (-) 😞

 

Dawid

sunny_talwar

Would you be able to share a sample where we can see this behavior? On another note, do you need dollar sign expansion? Can you try this?

RangeSum(vVar1, vVar2)
DawidDaw
Contributor III
Contributor III
Author

As I'm fully on server with database data, I would need to re-create everything from scratch. I'll see if I can work something out. 

 

Unfortunately, using the rangesum without the expansion doesn't work either.

 

Maybe I should mention de variables are set analysis:

sum({$<financials_state={"Actual"}, costType={"DirectCost"}>} financials_amount_euro_tax_excl )

sum({$<financials_state={"Actual"}, costType={"IndirectCost"}>} financials_amount_euro_tax_excl )

sunny_talwar

I am just trying to throw out different ideas for you to try... does this work? basically adding extra parenthesis around each variable.

($(vVar1)) + ($(vVar2))

or

RangeSum(
  ($(vVar1)), ($(vVar2))
)

 

DawidDaw
Contributor III
Contributor III
Author

Jup, thanks for the troubleshoot Sunny! Neither the first nor the second, both return " - ".

 

However I notice you don't use = sign when inserting variable. I always have " =$(vVar) in all cases and have NO equal sign in variable definition. This is the way it works for me (well, until now).

 

Can this be an indication?

 

sunny_talwar

Ya, you can try adding an equal sign and see if that works

=($(vVar1)) + ($(vVar2))

or

=RangeSum(
  ($(vVar1)), ($(vVar2))
)

 

DawidDaw
Contributor III
Contributor III
Author

What I mean is, I always use the equal sign. Don't really know the difference but that's the way I've always done it.

 

Removing or adding the equal sign doesn't help 😞

sunny_talwar

Can you post screenshots to show the issue? It is difficult to know what you might have without seeing it