Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

wonkymeister
Not applicable

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
Not applicable

Re: Conditional Show Columns with Multiple Selections

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


talk is cheap, supply exceeds demand
6 Replies
carlos_reyes_qv
Not applicable

Re: Conditional Show Columns with Multiple Selections

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
Not applicable

Re: Conditional Show Columns with Multiple Selections

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
Not applicable

Re: Conditional Show Columns with Multiple Selections

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
Not applicable

Re: Conditional Show Columns with Multiple Selections

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


talk is cheap, supply exceeds demand
wonkymeister
Not applicable

Re: Conditional Show Columns with Multiple Selections

cheers G - works a treat.

you're a fountain of knowledge mate

Not applicable

Re: Conditional Show Columns with Multiple Selections

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