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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Trying to put Expressions into Variables

I have a number of expressions in my document that I am using repeatedly, so I wanted to load them into variables.

First I defined them in the document using the Variable Overview and that works perfectly.

Best practices recommends loading them in the script, so I attempted to do that, but have had no luck getting it to work.

This is what Variable Overview shows if I define it in the document:

eCurrentYear = sum({$<@Year={$(=(@Year))},@Quarter = ,@Period = ,@Week = >}#InvoiceTotal)

  eLastYear = sum({$<@Year={$(=(@Year)-1)},@Quarter = ,@Period = ,@Week = >}#InvoiceTotal)

Life is good!


This is what Variable Overview shows if I define it in the script:

eCurrentYear = sum({$<@Year={(internal error)},@Quarter = ,@Period = ,@Week = >}#InvoiceTotal)

eLastYear = sum({$<@Year={(internal error)},@Quarter = ,@Period = ,@Week = >}#InvoiceTotal)


Does anybody have any idea what's causing the internal error, and how to get around it?

1 Reply
Anonymous
Not applicable
Author

Finally got it working, based on a previous post in the Community by Sunny Talwar.

LET etCurrentYear='sum({$' & '<@Year={$' & '(=(@Year))},@Quarter = ,@Period = ,@Week = >}#InvoiceTotal)' ;

LET eLastYear='sum({$' & '<@Year={$' & '(=(@Year)-1)},@Quarter = ,@Period = ,@Week = >}#InvoiceTotal@)' ;

I just needed the ' & ' after the $ signs. It now works as expected.