Variables do not expand before calculating

Possible cause  

Your variables may be missing an = sign at the beginning.

Proposed action  

The proposed action depends on where and how you are using the variable.

Qlik NPrinting, Qlik Sense, and QlikView treat variables the same way when used without a dollar-sign expansion. Therefore, if you need to use the evaluated result of the variable, there must be an = sign at the start of the variable definition. If the variable does not appear in a Scenario 2 case, you can modify its definition accordingly. This is valid for:

  • Dynamic naming
  • Conditions
  • Variables in email
  • Qlik NPrinting Designer variables

Dollar-sign expansion works by inserting the evaluated value of a variable as-is, in place of the full dollar-sign expansion . The value of a variable is the interpreted string inserted in the definition. It could be:

  • a string of text
  • a number (if the text is compatible with a number format)
  • a date (if it is a date)
  • the evaluated result of an expression, if it begins with =.

This means that an expression inserted in a variable definition, that does not begin with an equal sign, is in fact text.

If the variable is used within a dollar-sign expansion in Qlik Sense or QlikView, then you cannot change its definition. This would change the way the dollar-sign expansion works: it would insert the evaluated value instead of the text. In this case, you must create a second, identical variable with the same formula, but a different name. Use this new variable as you would in Scenario 1.

For example:

  • VarApp1: where sum(sales) is the variable definition. This is the original variable, and remains unchanged.
  • VarApp1b: where =sum(sales) is the variable definition. This new variable can be used in Qlik NPrinting in the cases described in Scenario 1.

If you do not want to define a new variable, but you need to use it in Qlik NPrinting Designer, you can use a formula to expand the variable as you would do in Qlik Sense or QlikView. For example =$(VarApp1).

If you applied a condition to a variable, and the variable does not calculate, the issue could be with the condition. Add the variable to a report without the condition, and run the publish task.

In the produced report you will see what value is being extracted. You can quickly verify if the variable resolves to a string or if a value is in fact being calculated.