Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I'd like to capture multiple field selections in the sheet title up to 3 selected items ordered by values. My current expression is like below, but it is not producing the output I need. I'd appreciate it if someone can tell me how to create a dynamic title with multiple field selections.
Thank you for your help.
GetFieldSelections() only shows values if selections have actually been made on the field. It won't show anything if you've not made any selections on the field.
Getting exactly three values, sorted by an expression, is doable, though if there are ties you may not get the results you expect. There might be a better way, but my approach here would be to use three individual FirstSortedValue() functions, one each for the first, second, and third value. You could also use Concat() sorted by your expression, and then use a string function to trim it down to just the top three values by finding the third separator - that might be a better option in that it would be able to deal with ties, I think.
Something along the lines of (not exact syntax since I can't test but hopefully this'll give you the general direction):
Left(Concat(YourField, ';',Balance),Pos(Concat(YourField, ';',Balance),';',3)))
Since you didn't mention what your actual data is and what the output you need is, it's quite hard to guess. The syntax itself looks correct (though you could use & ' expense for ' & instead of splitting that into two strings).
Hi,
Thanks for your feedback. I have the GL account name (Nature - Fixed Report) and employee name (Last name first name) dimension fields which I want to use in the title for the selected items. As those fields have many items within themselves, I want to limit the number of text strings from the fields to be no more than 3 items for each field. For unknown reasons, GetFieldsSelections expression which I tried above did not show any output in the title string, so I changed the formula to MaxString for the GL selection, and it is now only showing the last item on the alphabetical order, and MinString for employee name and it is only showing one employee who ranks 1st in the alphabetical order. Instead of alphabetical order, I'd like to have the order evaluated by the largest measure balance for both fields.
Thank you for your help.
GetFieldSelections() only shows values if selections have actually been made on the field. It won't show anything if you've not made any selections on the field.
Getting exactly three values, sorted by an expression, is doable, though if there are ties you may not get the results you expect. There might be a better way, but my approach here would be to use three individual FirstSortedValue() functions, one each for the first, second, and third value. You could also use Concat() sorted by your expression, and then use a string function to trim it down to just the top three values by finding the third separator - that might be a better option in that it would be able to deal with ties, I think.
Something along the lines of (not exact syntax since I can't test but hopefully this'll give you the general direction):
Left(Concat(YourField, ';',Balance),Pos(Concat(YourField, ';',Balance),';',3)))
Thanks a lot for your advice. I tried your recommended title expression, and I get a message "POS is not a valid function". I am assuming that for "Balance", I can just put the master measure, but it is still in black. Also, the "Pos" is also in black and I am wondering if text coloring in the syntax indicates whether it is correct or not.
Hello,
I also tried the syntax FirstSortedValue for the title expression, but I am not familiar with the Qlik Sense syntax and I am getting the following error message. I put in a field name from a dimension table as the first argument, and master measure name for the 2nd argument. But I am not sure what SetExpression in the syntax below should look like.
FirstSortedValue([{SetExpression}] [DISTINCT] [TOTAL [<fld {,fld}>]] value, sort_weight [,rank])
Thank you for your help.
Sorry, should be index() in Qlik, not Pos().
You can't use master measures in Qlik scripting unless you're using the most recent version - this option was introduced in the May 2021 version. Depending on what your measure actually is, it may or may not work in this context - if it's an aggregation function, you'll likely have to use aggr().
Thanks again, but I get the following error message, and I am not sure how I can fix it.
GetFieldSelections() function worked well. Thanks.