Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Not applicable

Dynamic ValueList using GetFieldSelections

Hi

(fairly new to Qlik)

I am trying to create a dynamic valuelist for a chart that needs to only display the current and prior 2 x Periods based on the current selected Period. My Period is based on date parameters, but are not calendar months starting on the 1st and ending on the last day of the month, so this gets calculated in another imported table.

I have added this as a dimension and it works great:

ValueList(getfieldselections(Period)-2,getfieldselections(Period)-1,getfieldselections(Period))

I have used this as my Measure expression:

if(ValueList(getfieldselections(Period)-2,getfieldselections(Period)-1,getfieldselections(Period))=getfieldselections(Period)-2,sum(if([Period]=getfieldselections(Period)-2,StockTotalExc)),
if(ValueList(getfieldselections(Period)-2,getfieldselections(Period)-1,getfieldselections(Period))=getfieldselections(Period)-1,sum(if([Period]=getfieldselections(Period)-1,StockTotalExc)),
if(ValueList(getfieldselections(Period)-2,getfieldselections(Period)-1,getfieldselections(Period))=getfieldselections(Period),sum(if([Period]=getfieldselections(Period),StockTotalExc)))))

I only get a result for my selected period, yet if I replace ... sum(if([Period]=getfieldselections(Period)-2,StockTotalExc) ... with the actual values as a non-variable throughout, I get it to work perfectly.

Any ideas?

1 Reply

Re: Dynamic ValueList using GetFieldSelections

Why do you need ValueList() function here? Have you tried using something like this:

Dimension: Period

Expression: Sum({<[Period] = {"$(='>=' & (Max(Period) - 2) & '<=' & 'Max(Period))"}>} StockTotalExc)

Community Browser