I like using “Show Frequency” in a Listbox, but the feature suffers two drawbacks.
- If the Field is in a Dimension table, the frequency — usually 1 — is not particularly useful to the user.
- Excluded (gray) rows show a blank frequency value.
As an alternative to “Show Frequency”, we can use the Expression pane of the Listbox to provide a more meaningful number, such as count of orders.
num( count(DISTINCT OrderID) ,'#,##0')
Listbox Expressions don’t provide for a heading. We can fake one by adding it the Listbox Title with enough spaces to align the heading.
The excluded values show zero. We can fix that by adding a Set to the expression. The Set should honor selections in other fields such as Product or Year, so we only need to ignore the selection in this field.
num( count({<Customer=>} DISTINCT OrderID) ,'#,##0')
Optionally, we can use the same expression as a Sort Expression if we want to sort by Order count.
There you have it. A more useful Frequency for the QlikView Listbox.
The Qlik Sense Filter Pane does not provide an Expression property, but you can achieve a similar result in Qlik Sense by creating the Field as an expression,
aggr( only({<Customer=>}Customer) & repeat(chr(160),8) &num( count({<Customer=>}DISTINCT OrderID) ,'#,##0') ,Customer)
The “repeat(chr(160),8)” is a trick to insert 8 “non-breaking” spaces. A string of multiple regular ‘ ‘ spaces will display as only a single space when displayed in the browser.
You may want to place the numbers on the left side to make the numbers clearer.
And yes, you could dynamically calculate the number of spaces required to get multiple digits right-aligned.
Using aggr() to create a Filter Box is a much “heavier calculation” than just using the Field. If you have a large application, test this technique for performance before deciding to use it there.
-Rob
The Qlik Sense field as expression is a very cool concept. Won’t it also populate your Current Selections with your formula? I would consider that a big UX limitation to consider as well before using it.
Speros,
My experience is that the Qlik Sense current selections will appear just as you would want: Customer 3 of 300. Selections made against a formula generated list are made in the underlying associated Dimensions values.
On Speros’s point my experience in Sense is a formula-generated list will show the whole formula in the current selections. I’ll have to check that one…
Jason, I think the difference here may be the use of aggr(). If you wrap your expression in aggr(), you are creating an association with a Dimension, and the dimension name will show in the current selections. Same concept applies here: http://qlikviewcookbook.com/2015/04/cell-popups-in-straight-table/
Can you do a similar thing to fields added in a Multi Box, as we often use these for our filter selections instead of List boxes to conserve space in the dashboard?
Dan, You can use Expressions to create fields in Multi-Boxes as in the Sense example above. Be sure to use the aggr() so selections get applied directly to the correct field.
Great to know this. Thank you Rob..
Very tricky Rob to display the non selected frequency.
Is it also possible to sort the values by the count (or sum) so that I can see the biggest one first.