Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

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.

Tags (1)
1 Solution

Accepted Solutions
Not applicable

Re: Variables in an Array

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

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

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

4 Replies

Re: Variables in an Array

Try it with quotes and/or dollar-expansion:

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

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

- Marcus

MVP
MVP

Re: Variables in an Array

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

Re: Variables in an Array

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

Not applicable

Re: Variables in an Array

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

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

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

Community Browser