Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
There are several field functions that can be used in Qlik Sense and QlikView charts to return information about a field and/or selections in an app. They are:
In this blog, let’s take a look at how each of these functions can be used in your chart expressions.
GetSelectedCount
getselectedcount(field_name [, include_excluded])
This function returns the number of selected (green) values in a field.
The GetSelectedCount of the Product Group field below will return 3 for the 3 selected (green) items.
If the optional include_excluded parameter is set to True(), the returned count will include selected values which are currently being excluded by selections in other fields. If it is False() or omitted, then these values will not be included in the count. In the image below, the selection of Jam and Jelly in the Product Sub Group field has excluded Alcoholic Beverages and Baked Goods so they are now gray instead of green. The GetSelectedCount function for the Product Group will now return 1. If the include_excluded parameter is set to True(), then it will return 3, counting the excluded selections.
GetSelectedCount([Product Group]) = 1
GetSelectedCount([Product Group], True()) = 3
GetAlternativeCount
getalternativecount(field_name)
This function returns the number of alternative (light gray) values in a field.
The GetAlternativeCount of the Region Name field below will return 3 for the light gray items in the field.
GetPossibleCount
getpossiblecount(field_name)
This function returns the number of possible values in the field. If the field includes selections, then the selected items (green) are counted. Otherwise associated (white) values are counted.
In the image below, the GetPossibleCount function for the Product Sub Group field will return 3 for the 3 associated (white) items in the list.
If I were to select Muffins in the Product Sub Group field (see image below), then the GetPossibleCount function will return 1 for the selected item.
GetExcludedCount
getexcludedcount(field_name)
This function returns the number of excluded (dark gray) values in the field.
In the image below, GetExcludedCount of the Product Line field would return 1 for Drink which is dark gray.
GetCurrentSelections
getcurrentselections([record_sep [,tag_sep [,value_sep [,max_values]]]])
Unlike the other functions we have looked at so far, this function returns a string containing the current selections in an app. The optional tag_sep parameter allows you to select the separator between the field name tag and the field values. The default is a colon (:). The optional value_sep parameter allows you to select the separator between the field values. The default is a comma (,). The optional max_values parameter allows you to set the maximum number of field values that can be individually listed. The default is 6 and anything more than that is shown as 'x of y values'.
In the image below the GetCurrentSelections function will return the following:
Product Group: Beverages
Product Line: Drink
Product Sub Group: Juice, Soda
GetFieldSelections
getfieldselections(field_name [, value_sep [, max_values]])
This function also returns a string with the current selections for a field. The optional value_sep parameter allows you to select the separator between the field values. The default is a comma (,). The optional max_values parameter allows you to set the maximum number of field values that can be individually listed. The default is 6 and anything more than that is shown as 'x of y values'.
In the Product Sub Group filter pane above, Juice, Soda will be returned by the GetFieldSelections for the Product Sub Group field.
Field functions provide valuable information about selections in a field that can be used in an app to display information or help determine if another action needs to take place. For instance, if more than one field value is selected, do something. Try using a field function next time you are building an app to see how they work.
Thanks,
Jennell
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.