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: 
Not applicable

Variables in an Array

last weekend I was tired of the intensive use of variables for expressions, dimensions, comments and tiles in my charts so I was thinking about how to reduce them. I finally tried something warea storing the values in arrays and using subfield() commands in the charts to select the proper variable. The idea was as follows.

definition of the variable:

SET vSales = ('Total Sales';'Sales';sum(sales);'total sales per...')

in the charts I would then use a subfield command for selecting the proper content:

subfiled($(vSales),';',1) for title

subfiled($(vSales),';',2) for expr text

subfiled($(vSales),';',3) for expr formula

subfiled($(vSales),';',4) for expr comment


what am I doing wrong here? ESpecially the formula does not work.

1 Solution

Accepted Solutions
Not applicable
Author

Thanks to Marcus Sommer the working commands for the formula look like follows:

= $ (= subfield ( vSales , ' ; ' , 2)    or

= $ (= subfield ( ' $(vSales) ' , ' ; ' , 2)

View solution in original post

4 Replies
marcus_sommer

Try it with quotes and/or dollar-expansion:

= $(=subfield($(vSales), ',', 3))

= subfield('$(vSales)', ',', 3)

- Marcus

jagan
Partner - Champion III
Partner - Champion III

Hi,

Try like this

SET vSales = 'Total Sales;Sales;sum(sales);total sales per...';

let vTotalSales = subfield('$(vSales)',';',1) ;

let vSales = subfield('$(vSales)',';',2) ;

let vSumSales = subfield('$(vSales)',';',3) ;

Regards,

Jagan.

Not applicable
Author

Thanks, but this was exactly the target --> avoidance of too many variables in order to keep them manageable

Not applicable
Author

Thanks to Marcus Sommer the working commands for the formula look like follows:

= $ (= subfield ( vSales , ' ; ' , 2)    or

= $ (= subfield ( ' $(vSales) ' , ' ; ' , 2)