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: 
Anonymous
Not applicable

Use GetFieldsSelection in Aggregations

Hello,

I would like to achieve the following in QlikView:

I have a list box "Parameter" listing all fields by using $Field. If I select one element from Parameter I would like to get min(), max(),avg() for that field in a text box. I tried something like: =max($(=GetFieldSelections($Field))) . But that does not work.

I just want to replace the literal field name by the selected value. How can this be done?

Thank you

12 Replies
lironbaram
Partner - Master III
Partner - Master III

hi

try this

='min: '  & $(='min([' & $Field & '])') & chr(10) &

'max:' &  $(='max([' & $Field & '])')  & chr(10) &

  'avg:' &  $(='avg([' & $Field & '])')  & chr(10) &

   'median:' &  $(='median([' & $Field & '])') 

tresesco
MVP
MVP

This should work when you select a single field from the listbox $Field. However, if your field name has space in between, you might have to try like:

=Max($(='['&getfieldSelections($Field)&']'))

sergio0592
Specialist III
Specialist III

Hi,

So it should works if you create a variable V_selected_field

=GetFieldSelections([$Field])

Use this var in the text box with : =max($(V_seleted_field))

qliksus
Specialist II
Specialist II

Just put this in a variable   Variable1=GetFieldSelections($Field)    and  use something like

max($(Variable1))

sasikanth
Master
Master

HI Tobias,

try below expression

=max({<$Field={$(=GetFieldSelections($Field))}>} $(vNew))


where vNew is a variable (vNew=getFieldSelections($(Field))

Anonymous
Not applicable
Author

Unfortunately, that does not work for me. The result is empty.

Anonymous
Not applicable
Author

This appears to work ... almost. If I apply the formula to avg() and max() the result is plausible.

However, for min () it is not. Is there a way to display all values that contribute?

I tried to make a table based on GetFieldSelections() but obviously I have not grabbed the mechanics of referencing right.

Anonymous
Not applicable
Author

OK. I got it now. My Diagram does not show all values for some reason.

so =Max($(='['&getfieldSelections($Field)&']')) solved my problem.

Thank you very much.

Anonymous
Not applicable
Author

Actually, I am still missing something. I get wrong values for min, max, avg.

What I did not mention before is that I have a second selection "ModelName" in a list box. Maybe this has an impact.

I have a line diagram and list box showing the selected values consistently if I select a ModelName and a Field.

But the aggregations do not reflect the values that I see in list box like a higher Max than any value in the selected list.

It appears that Max is also not global: If I deselect all ModelName then I get different values than when selecting one.

Do I have to explicitly filter for Model and how do I do it?