Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Call set analysis by variable in a chart

Hello Community,

I learnt that I cannot call set analysis contains variables in onther variable and use the second variable in the chart.

For instance:

If I use the following formula directly in my chart and it works;

sum( {1 <[dimension]={">=$(vVariable1)<=$(vVariable2)"}> } SALES)

If I set the same formula in the variable and call this variable within my chart, the value is empty.. Why?

Thank you for any clues.

Best regards

4 Replies
JonnyPoole
Employee
Employee

Do you have an '=' sign at the beginning of the expression when you define the variable ?

Do you have this: 

sum( {1 <[dimension]={">=$(vVariable1)<=$(vVariable2)"}> } SALES)


or this: 

=sum( {1 <[dimension]={">=$(vVariable1)<=$(vVariable2)"}> } SALES)

If you haven't tried the first, i'd suggest that and invoke the variable with $() expansion  ex:   $(vVariableName)

chrislofthouse
Partner Ambassador
Partner Ambassador

What about this:

sum( {1 <[dimension]={">=$(=$(vVariable1))<=$(=$(vVariable2))"}> } SALES)

Not applicable
Author

The right expression is:

     sum( {1 <[dimension]={">=$(vVariable1)<=$(vVariable2)"}> } SALES)

without pre equal-sign.

Peter_Cammaert
Partner - Champion III
Partner - Champion III

Watch out if you set variables to values that should keep other variables safe from $-sign substitution. If you want to use a variable called vSalesExpression and set it to the expression of your chart, you can do this as-is in the variable overview.

In your script however, you have to make sure that the two embedded variables do survive the assignment, like in:

LET vSalesExpression =  'sum( {1 <[dimension]={">=$' &

                        '(vVariable1)<=$' &

                        '(vVariable2)"}> } SALES)';

In any case, make sure that in the end the substituted text contains exactly one equal sign (not two), as Jonathan suggests.