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: 
shinnickr
Creator II
Creator II

Conditional hide/show columns with multiple selections.

Hi there,

I have a bit of a weird problem.  I have been tasked with showing/hiding columns based on a current selection.  I am able to do that with a condition like:

if(isnull(GetFieldSelections([Rule Description])), 1, 0)

OR

if(Index([Rule Description], 1, 1), 1, 0)

OR

if(Index([Rule Description], 2, 1), 1, 0)

OR

if(Index([Rule Description], 4, 1), 1, 0)

OR

if(Index([Rule Description], 5, 1), 1, 0)

OR

if(Index([Rule Description], 14, 1), 1, 0)

So, if there is no selection, show all the fields.  If the [Rule Description] field has a 1, show the column else hide it, etc.

The problem I've run into, is that if someone selects multiple [Rule Description]s it doesn't show any of the columns with this formula in it.  What are my options for getting around this?  Any ideas?

Thanks!

1 Solution

Accepted Solutions
shinnickr
Creator II
Creator II
Author

After some trial and error I managed to get this to work.

I have 14 different [Rule Description]s, all numbered 1), 2), 3), etc.  So using the formula below I am able to do - if no [Rule Description] is selected, show the column.  And then when the selection has a '3) ' in it, show the selection.  By doing the wildmatch I was able to show the required columns with multiple selections.

if(isnull(GetFieldSelections([Rule Description])), 1, 0)

OR

if(wildmatch(getfieldselections([Rule Description]),'*3) *'), 1, 0)

OR

if(wildmatch(getfieldselections([Rule Description]),'*8) *'), 1, 0)

OR

if(wildmatch(getfieldselections([Rule Description]),'*9) *'), 1, 0)

OR

if(wildmatch(getfieldselections([Rule Description]),'*10) *'), 1, 0)

OR

if(wildmatch(getfieldselections([Rule Description]),'*11) *'), 1, 0)

OR

if(wildmatch(getfieldselections([Rule Description]),'*12) *'), 1, 0)

I hope this makes sense for anyone who might possibly have the same problem that I did!

View solution in original post

14 Replies
pradosh_thakur
Master II
Master II

try this

if(wildmatch(getfieldselections([Rule Description]),*1*)>0,[Rule Description])

Learning never stops.
shinnickr
Creator II
Creator II
Author

I get an error in expression during the end part.  if(wildmatch(getfieldselections([Rule Description]),*1*)>0,[Rule Description])

pradosh_thakur
Master II
Master II

if(wildmatch(getfieldselections([Rule Description]),"*1*")>0,[Rule Description])


Missed the quotes

Learning never stops.
Mark_Little
Luminary
Luminary

HI Ryan,

Not sure exactly how you are trying to show and hide fields. Could you maybe explain a little more in plain English the logic to show and hide?

But from your above script

if(Index([Rule Description], 1, 1), 1, 0)

You are not comparing the result i.e Index([Rule Description], 1, 1) = 'Something',1,0

Mark

shinnickr
Creator II
Creator II
Author

Looks like it's single quotes instead of double.  But it's actually showing all of the columns when I choose a single rule now, instead of just the ones I filtered on. I think because of the >0?  I will continue working with it!

Anonymous
Not applicable

Try

=SubStringCount(concat ([Rules Description],'|'),1)

shinnickr
Creator II
Creator II
Author

Hi Mark,

I am using the "Enable Conditional" selection in the chart properties.


So if(Index([Rule Description], 1, 1), 1, 0) - If there is a 1 in [Rule Description], show(1), else hide(0).  This is working for me on a single selection level.  So if I put this into 5 out of the 10 columns, when choose a [Rule Description] with a 1 in it, it shows the 5 columns I want to, and hides the other 5.  But if I choose multiple [Rule Description], it does not show any of the columns with the conditional filtering on it.


Does this make any more sense?  I'm sorry if I'm being confusing!  If there's anything else I can elaborate on that might be more helpful let me know.

Mark_Little
Luminary
Luminary

Hi,

It is probably worth taking a look at the link below,

Dynamic Tables and Graphs

This is the approach to making table where columns are shown and hidden depending on selections.

Mark

shinnickr
Creator II
Creator II
Author

I took a look and tried to make it work and maybe I'm not fully understanding it, but I don't think it's exactly what I'm looking for.  That is hiding/showing columns based on multiple different dimensions being chosen.  I am looking to hide/show the columns based on a single dimension.