Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
tinkerz1
Creator II
Creator II

Get selected fields, alternate states and expressions in charts

After setting up list boxes with alternate groups I now want to call the selections in a chart expression.

my code is:

Sum({$<{[OHRO]}[MARKET RISK: NOTE: on target + overdue = LIVE ISSUES]={'Red Threshold'},Getselectedfield from {[OHRO]}[Group]>}Data)

But I cant figure the item in red?

How do I 'getselectedfield'

Neil

10 Replies
sunny_talwar

By Group you mean Cycle or DrillDown Group?? Not sure what you mean because there is no function called GetSelectedField. There are few like GetCurrentField(), which is used with Cycle or DrillDown Group, but based on your question, you may need something else.

morganaaron
Specialist
Specialist

Hi Neil,

If you're talking about using the GetFieldSelections() function within a search string inside set analysis, the ability to define which state you want to reference was added for SR9 or 10 I believe.

You can use GetFieldSelections([Your Field], [Your value separator], [State]).

However, looking at your expression, you may want to use the element function P() instead - or use the $:: function to synchronise your selections between states.

If you look up 'examples of alternate states in chart expressions' in Qlikview Help it has a fuller explanation.

tinkerz1
Creator II
Creator II
Author

Hi there,

I am using QV11 with alternate states, it looks like GetCurrentField() and getfieldselections does not work on charts with alternate states?

Thanks.

tinkerz1
Creator II
Creator II
Author

Hi I thought the code was

GetfieldSelections([Your field],[You Value seperator],[Maxvalues])

That is what my help file is saying, is there any online help topics for this?


Anonymous
Not applicable

GetFieldSelections() has a parameter for State, Helptext pasted in below.

getfieldselections ( FieldName [, ValueSep [, MaxValues [, State]]])

Returns a string with the current selections in a field. It is possible to query an alternate state.

ValueSep is the separator to be put between field values. The default is ', '.

Maxvalues is the maximum number of field values to be individually listed. When a larger number of values is selected the format 'x of y values' will be used instead. The default is 6.

State is the alternate state to query.

The string that is returned can be in these forms:

   

'x, y,z'If the number of selected values is Maxvalues or less, the string returned is a list of the selected values, separated with Valuesep as delimiter.
'NOT x, y, z'If the number of non-selected values is Maxvalues or less, the string returned is a list of the non-selected values, separated with ValueSep as delimiter, and NOT as a prefix.
'x of y'If the number of selected values is more than Maxvalues, but less than the total number of values (y) less Maxvalues.
'ALL'If all values are selected.
'-'If no value is selected.
<search string>If you have selected using search, the search string is returned.

Examples

getfieldselections ( Year )

getfieldselections ( Year, '; ' )

getfieldselections ( Year, '; ' , 10 )

tinkerz1
Creator II
Creator II
Author

Maybe I dont have the right version as this errors.

My version is 11.20.12577.0 SR8

Sum({[OHRO]<[MARKET RISK: NOTE: on target + overdue = LIVE ISSUES]={'Amber Threshold'},getfieldselections([Group],';',10,OHRO)>}Data)

tinkerz1
Creator II
Creator II
Author

My version is 11.20.12577.0 SR8,

which version has the function getfieldselections ( FieldName [, ValueSep [, MaxValues [, State]]])


with state on it, I have the free version which is not on there


thanks

morganaaron
Specialist
Specialist

Hi Neil,

SR8 was the first version to include this function, so you should be able to use it. I believe the help wasn't updated until SR9 or SR10 to include this, but in the release notes it states you can do this from SR8.

Note that the state needs to be written in quotation marks.

Just referencing your expression, you haven't got anything preceding your GetFieldSelections expression, so at the minute I don't think this will be working correctly. If you want to filter on the "Group" field based on the selections of another state, you may be better off using:

Sum({[OHRO]<[MARKET RISK: NOTE: on target + overdue = LIVE ISSUES]={'Amber Threshold'}, Group=OHRO::Group>}Data)

Which would synchronise your selections in the field Group from the state OHRO with your equation. You can also use:

Group=P({OHRO}Group>}Data) which will pass any possible values to the other state, so it's not just a selection in the field group that would affect the result, but any selection in that state that narrows the possible values in the field group.

If you wanted to use the GetFieldSelections function you'd need to turn this into a search string, and also convert the values it returns into a valid selection set.

tinkerz1
Creator II
Creator II
Author

I would just like some direction on the below statements:

Sum({[OHRO]<[ABC]={'Amber Threshold'}, Group=OHRO::Group>}Data).

Even though you synchronise your selections in the field Group from the state OHRO, it only matters in the above equation what you select on in OHRO group state, so what is really inherited if selections in the higher level group if that group has selections or not?

In the below statement I can't see what is going on:

Sum({[OHRL]<[ABC]={'OPEN-High-Live'},Group=P({OHRL}Group>}Data)

If I select the higher group,ABC or Group and selections in OHRL, the selections turn green but nothing charts, so I cant see what is going on with the P function.

I thought what ever you select in P({OHRL}Group will chart if OPEN-High-Live is selected in [OHRL]

Thanks