Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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
tresesco
MVP
MVP

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
Champion
Champion

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

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

tresesco
MVP
MVP

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

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

tresesco
MVP
MVP

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.

sunny_talwar

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?

Anonymous
Not applicable
Author

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.

tresesco
MVP
MVP

Could you share your sample qvw?

Anonymous
Not applicable
Author

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

sunny_talwar

Share sample raw data and expected output?