Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Announcements
Qlik® Product Spotlight: Discover what’s possible. Get more from our products.
See for yourself. Register today.
adwitiya
Contributor

Extract fields from GetFieldSelections

I have [Month] as a filter. I want to be able to select certain months at a random order and run a part of a code for those Months alone.

if(GetSelectedCount([Change])=1 and GetSelectedCount(Month)=1 ,

        if(avg(TransitionMonthNum)>=num(Month),

                Rangesum(above(total(sum({<Version={'1YP'}>}Value)),0,rowno(total)))

              + sum(total {<TransitionMonth={'$(=getfieldselections(Month))'} , Version={'1YP'}>}Value)*[Change]/100,

                Rangesum(above(total(sum({<Version={'1YP'}>}Value)),0,rowno(total)))

                )

              )


The above code works when only one [Month] is selected. I want this to run when GetSelectedCount(Month)>1 and have the values from GetFieldSelections(Month) in an array or something, and then create a loop, so that the code works for all the months selected.

What would be the best way to do this?


14 Replies
MVP
MVP

Re: Extract fields from GetFieldSelections

May be like:

TransitionMonth={'$(=chr(39)&GetFieldSelections(Month, chr(39)&','&chr(39))&chr(39))'}

This would generate comma separated; single quoted values in set analysis

YoussefBelloum
Esteemed Contributor

Re: Extract fields from GetFieldSelections

you can use this set analysis also like suggested by omarbensalem‌ last time:

TransitionMonth={"$(=concat(Month,'","'))"}

MVP
MVP

Re: Extract fields from GetFieldSelections

A bit of correction: remove the starting and ending single quotes, like:

TransitionMonth={$(=chr(39)&GetFieldSelections(Month, chr(39)&','&chr(39))&chr(39))}

MVP
MVP

Re: Extract fields from GetFieldSelections

With concat() you would need additional check if there is a selection or not. Because, even if you don't select from the field, it would return all values.

Re: Extract fields from GetFieldSelections

What is your chart dimension/s here? Would you be able to share an image of what you have and what are you hoping to get?

adwitiya
Contributor

Re: Extract fields from GetFieldSelections

Hi, tresesco‌ and youssefbelloum

Please let me explain the problem better.

So I have a line chart with Month on the X-axis and cumulative sum(Value) as a measure.

The field [Change] is a number between -50 to +50. If Change=+10 and Month='Aug', The [Value] for Aug increases by 10%. So the [Value] for each month that comes after Aug changes too. (Since it is Cumulative).

Now I want to be able to select multiple Months and change the graph accordingly.

MVP
MVP

Re: Extract fields from GetFieldSelections

Could you share your sample qvw?

adwitiya
Contributor

Re: Extract fields from GetFieldSelections

I'm working on Qlik Sense Enterprise, so don't have a QVF.

Re: Extract fields from GetFieldSelections

Share sample raw data and expected output?