Qlik Community

App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Now Live: Qlik Sense SaaS Simplified Authoring – Analytics Creation for Everyone: READ DETAILS
Showing results for 
Search instead for 
Did you mean: 
Contributor III
Contributor III

Use dimension as variable parameter

Hi all,

This is driving me nuts. I have a field full of integers (from 1 to 12, called "Loop", I also tried to generate this via ValueLoop with no luck), and a variable that gets an integer as parameter.

When I enter (in a straight table) the field as dimension and the variable with the dimension name as parameter, it returns 0 for all rows. When I enter the variable with a set parameter, it works. 

My final goal is to do an aggr sum over "Loop" field, that sums the variable evaluated in each of the "Loop" members and multiply it for a weighting formula that depends on the "Loop" values.

Attached you can find an image of what I'm doing.

Thank you all...

Labels (4)
2 Replies

Can you share your variable definition please

Contributor III
Contributor III

Hi Lisa, thanks for your time. the definition is:

vFcst_($1) = Sum({$<TipoDoc = {'BQ', 'BR', 'B8'}, AñoMes = {$(=$(vAñoMes($1)))}, Año=, Mes=>} Piezas)

It is the forecast (tipodoc means these are for forecast), in the selected year/month (vAñoMes($1)) in units (piezas), ignoring year (año) and month (mes) when selected.

vAñoMes($1) = 

If($1 = 0,
   If($1 < 0,
      If(Max(Mes) <= -$1,
         (Max(Año) - 1) * 100 + Max(Mes) + (12 + $1),
         Max(AñoMes) + $1),
      If(Max(Mes) > (12 - $1),
         (Max(Año) + 1) * 100 + Max(Mes) - (12 - $1),
         Max(AñoMes) + $1)))

It is the year * 100 + month, so when I do a set analysis on a selected month it works with only one condition, for the current, previous 12 or next 12 year/months.