Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
wonkymeister
Creator III
Creator III

Conditional Show Columns with Multiple Selections

Afternoon

i have a straight table with too many columns! so, I've decided to implement conditions on each column (which are expressions) which will determine whether each column is displayed or not.

to do this i have created an inline load such as:

ColumnSwitch:

Add Load * Inline

     [

     ColumnName

     Age

     Ethnicity

     Domicile

     etc....

     ];

these values then sit as a selection on the dashboard - and when the user selects a value which meets the selection the column displays in the table - easy.

ie

=if (ColumnName = 'Age',1,0)

now the tricky part. the user can select more than one value from the selection box - so i need to test a string of values which could > 1

so how do a test for any given value in the selections? ie GetFieldSelections(ColumnSwitch.ColumnName) if there's only one value then its fine - but if there's more than one using a simple ColumnName = 'Age' doesn't work.

thanks in advanced

1 Solution

Accepted Solutions
Gysbert_Wassenaar

No problem, you can add a condition to it: if(getselectedcount(ColumnName) and substringcount(... etc


talk is cheap, supply exceeds demand

View solution in original post

6 Replies
Carlos_Reyes
Partner - Specialist
Partner - Specialist

I recommend you to use:

Substringcount(Concat(ColumnName, '|'),'Age')

You'll have to change "Age" for each column/expression, and this way you can enable multiple columns when multiple selections are made in the ColumnName field.

Gysbert_Wassenaar

You can use substringcount for example, or wildmatch. For example If(substringcount(concat( '@' & ColumnName & '@'),'@Age@'), 1,0). The @'s are to reduce false positives in case another value in your field also contains the same substring.


talk is cheap, supply exceeds demand
wonkymeister
Creator III
Creator III
Author

G, that works,but, all the columns are displaying by default?

so i've applied the conditions to each expression, and with nothing selected the full table is displayed by default. its only when something is selected that the table changes to only display whats selected. i need the base table to have no columns unless something is selected.

sorry - i'm a wee bit confused.

Gysbert_Wassenaar

No problem, you can add a condition to it: if(getselectedcount(ColumnName) and substringcount(... etc


talk is cheap, supply exceeds demand
wonkymeister
Creator III
Creator III
Author

cheers G - works a treat.

you're a fountain of knowledge mate

Not applicable

Hello there,

would you be able to help me with this? I am not familiar with the formulas you mention but they may be the solution to my current issue. I have some columns I want to display based on a list box with multiple fields. if the users checks one, then I want to show the column, if the users checks 2 or more, then I want to show the number of columns the user wants to see. if there is no selection, then no columns should show.

I don't know how to combine the formula you mention, can you please give me the complete formula? I can replace with real column names and fields.

Thank you,

Hugo