Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
BHoll
Contributor III
Contributor III

Passing the result of GetFieldSelections()

Hello everyone,

i want to create a TextBox which counts the distinct values of a certain field. The user should be able to select the field in which the values get countet by using the $Field listbox.

I created a texbox with the following Code:

=Count(Distinct(GetFieldSelections($FIeld))

Instead of getting the distinct Count of the selected field in the listbox $Field, i only get a 1 if something is selected and 0 if nothing is selected.

 

best regards,

BHoll

1 Solution

Accepted Solutions
marcus_sommer

Try it with: = count(distinct [$(=$Field)])

- Marcus

View solution in original post

3 Replies
marcus_sommer

Try it with: = count(distinct [$(=$Field)])

- Marcus

BHoll
Contributor III
Contributor III
Author

Hi Marcus,

working perfectly fine with you syntax, thank you.

Can you explain to me how the dollar and equal sign gets interpreted by QlikView in your formula?

And whats the reason that my formula didn't work. Is it not possible to pass a Fieldname to a function like this?

marcus_sommer

The result of a Qlik expression is either a number or a string but not a field - completely independent if it looked like a valid fieldname. Unfortunately there is no evaluate() function available within the UI so that the only possibility to resolve any string as field is to store it as a variable.

My example is called a $-sign expansion and creates an adhoc-variable which are always evaluated at first on a global level and those results are treated as if the user has written them manually.

More to this could you find here: The-Magic-of-Dollar-Expansions

- Marcus