Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Not applicable

create varible in script based on multiple listbox selections

can I create a variable in script that concatenates and stores up to three selected fields in three separate list boxes?

For example:

vCondition = concat(getfieldselection(SubRegion),getfieldselection(Quarter),getfieldselection(GBU))

6 Replies
MVP
MVP

Re: create varible in script based on multiple listbox selections

getfieldselection doesn't work in the script

s_kunte23
Contributor III

Re: create varible in script based on multiple listbox selections

Hi,

Like Massimo posted,this won't work in script. But you can assign an action to a button which sets a variable value . Defining this you could use = concat(x,'/') & '/' & concat(y,'/')

The variable defined this way can be called in script.

Best regards

Stefan

Not applicable

Re: create varible in script based on multiple listbox selections

I need the targets to change when the filter is clicked so I don't want to put an extra button because that would take away from the usability of the site. can I use the above statement on all three fields? A user may click on only one or on all of the three possible fields.

s_kunte23
Contributor III

Re: create varible in script based on multiple listbox selections

Hi,

in this case you need a field trigger for each of these listboxes, thought you wanted this in your load script. in all 3 Triggers use  set Variable as action, which all set vCondition. The above formula will return also possible values and not only selected values. If you don't want unselected fieldvalues in this variable, modify it for example to:

=if(getselectedcount(FiscalYear) > 0, concat(distinct FiscalYear,'/') & if(getselectedcount(FiscalYear) >0, '/') ) & if( getselectedcount(FiscalYear) >0, concat(distinct FiscalYear,'/'))

But if this works depends on what you need the variable value for.

Best regards

Stefan

maverjannet
Valued Contributor

Re: create varible in script based on multiple listbox selections

Hi,

For attaching a field, yuo can use:

SubRegion&''&Quarter&''&GBU

Not applicable

Re: create varible in script based on multiple listbox selections

I do want this in the load script but you mentioned adding an action to a button and I don't want that. is there a way to add it to my load script without using a button? or did I misunderstand you?

As I have been working on this I tried another angle and I have created and loaded a table with all the target values I need.  There are two columns > Condition and TargetHow would I match the fields chosen by the user to the condition column?

For example:

User chooses SubRegion > EMCIE, Quarter > Q2, GBU > ABS from the associated listboxes.

My condition is EMCIEQ2ABS.

How do I tell the filters chosen to go look up and match the value in the Condition column?

I was able to get the selected fields using

=only(SubRegion)&only(Quarter)&only(GBU)

This returns the same value as above: EMCIEQ2ABS.

However if I try to use the statement

=if(Condition=only(SubRegion)&only(Quarter)&only(GBU),Target,0)

it always returns 0 instead of the Target value unless I manually select the matching field in the Condition listbox.

I need the filters selected to go select the corresponding value in the Condition box. This is where I'm stumped.

Community Browser