Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Listbox Default No Selection

Hello,

I have a list box that is tied to a straight table.  I want only the items in the listbox which are selected to show as columns in the table.  This part I have figured out. However, I know that with QlikView, no selection in a listbox essentially means "select all".  Since I have over 200 possible selections for fields to show on the report, I actually want no selection in my listbox to show NO fields at all.  Is there any way I can accomplish this?  I have not been able to find a setting or anything of the like.  I do not want to do "always one selection" because a user should be able to choose as many as they want and there should be no "default".  The "default" should be to show no fields.

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Well, if you use one field in selection and another in condition, my approach is not going to work.  So, you either use the same field in both places (as I thought you did), or stay with concat() function but add additional condition for "there are selections".


1. If you're willing to use the same field in the expression condition which you use in selection, it will be (for the same INDUSTRYSEGMENT expression):

index(GetFieldSelections(%_GenProjText, '|',300),'Industry Segment')

Notice that I use index() instead of substringcount() - it never returns '-'.  It will be 0 if there is no matching string

2. If you want to keep two different fields in selection and in condition, you have to stay with concat(), but I recommend to switch to index() too, and add conditions for selections:

index(Concat([_GenProjField], '|'),'INDUSTRYSEGMENT')>0 and GetSelectedCount(%_GenProjText)>0

Hope this time it helps...

Regards,
Michael

View solution in original post

12 Replies
Anonymous
Not applicable
Author

Kerri,

What are the conditions to show columns?  If you base conditions on GetFieldSelections() - you shouldn't have this problem.

Regards,

Michael

Not applicable
Author

Each possible column (all 200+ of them) is it's own expression in the table with the conditional show like this: SubStringCount(Concat([_GenProjField], '|'),'INDUSTRYSEGMENT').  If there is a better way you know of I can do this, please, I'd like to hear it!

Anonymous
Not applicable
Author

Just replace concat with GetFielldSelections, and you'll by fine, I think:

SubStringCount(GetFieldSelections([_GenProjField], '|'),'INDUSTRYSEGMENT').

Not applicable
Author

I did that, but now the field shows always.  Whether it's selected, greyed or there is no selection made in the lsitbox.  If there are no GREEN selections in the listbox, I want NONE of the fields listed to show.

Anonymous
Not applicable
Author

I missed one nuance.  You have a rather large number of values in the [_GenProjField].  If it is >200, change the expression a little:

SubStringCount(GetFieldSelections([_GenProjField], '|', 300),'INDUSTRYSEGMENT').

To see how it works and to troubleshoot, create two text boxes.
=Concat([_GenProjField], '|')

=GetFieldSelections([_GenProjField], '|', 300)

And make selections in the list box.  The results in the two text boxes should be identical, except there should be nothing in the 2nd if nothing is selected.

Let me know what you see.

Regards,

Michael


Not applicable
Author

The 1st text box is showing the correct values, except when no selection is made.  The second text box shows only '-' no matter the selection (or lack thereof).

Anonymous
Not applicable
Author

Are you sure there is no mistyping in your text box?  I know for sure that the function works.  Unless you have a rather old QV version...

Can you upload an example?

Not applicable
Author

I have found the issue and have it showing the correct selection (my selection value is actually different than the field name behind it)... but where do I put this conditional?  I have uploaded my full example (it's rather complex) and I'm not sure where on the table to place this condition so that only the selected fields show in the table.  The listbox(es) I'm using is the container titled "Available Fields".  I currently have each one of these fields as an expression in my table, but maybe that's not the correct solution here.  Thanks for your help!!

Anonymous
Not applicable
Author

Well, if you use one field in selection and another in condition, my approach is not going to work.  So, you either use the same field in both places (as I thought you did), or stay with concat() function but add additional condition for "there are selections".


1. If you're willing to use the same field in the expression condition which you use in selection, it will be (for the same INDUSTRYSEGMENT expression):

index(GetFieldSelections(%_GenProjText, '|',300),'Industry Segment')

Notice that I use index() instead of substringcount() - it never returns '-'.  It will be 0 if there is no matching string

2. If you want to keep two different fields in selection and in condition, you have to stay with concat(), but I recommend to switch to index() too, and add conditions for selections:

index(Concat([_GenProjField], '|'),'INDUSTRYSEGMENT')>0 and GetSelectedCount(%_GenProjText)>0

Hope this time it helps...

Regards,
Michael