Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
shinnickr
Creator II
Creator II

Conditional show/hide columns based on contents of another column

Hi there,

I have a bit of a weird situation and I'm hoping someone will be able to help.

Right now I have a straight table with multiple columns that have conditional formatting to show different columns based on a selection.  The code for this is:

if(isnull(GetFieldSelections([Rule Description])), 1, 0) // Always shows column if no selection is made

OR

if(wildmatch(getfieldselections([Rule Description]),'*1)*'), 1, 0) // Shows column if selection is like 1)

OR

if(wildmatch(getfieldselections([Rule Description]),'*2)*'), 1, 0) // Shows column if selection is like 2)

This is working as intended, showing or hiding the different columns based on the [Rule Description] selection.

The problem I'm having now is getting the columns to also show or hide if the [Rule Description] column only has one DISTINCT value in it.

For example:

If someone makes a selection of a different filter ( [Code Center] ) and the selection filters the data to only have values of "1)....", I would also like to show the columns as if the [Rule Description] "1)....." was filtered upon.

Anyone have any ideas on what I can do to get this to work?  I have tried FieldValue() but I could not get it to work as intended.

1 Solution

Accepted Solutions
31 Replies
avkeep01
Partner - Specialist
Partner - Specialist

Hi Ryan,

Try GETSELECTEDCOUNT(<fieldname>)

shinnickr
Creator II
Creator II
Author

Unfortunately I'm looking for something to find the values of the columns not the count of them.  "1)...." is actually a string value in the [Rule Description] field, not a number.

avkeep01
Partner - Specialist
Partner - Specialist

Hi Ryan,

Sorry, I based my answer on this comment:

The problem I'm having now is getting the columns to also show or hide if the [Rule Description] column only has one value in it.

because with GETSELECTEDCOUNT() it returns 1 if only one value is selected and 0 when nothing is selected. Perhaps you could use a combination:
IF(GETSELECTEDCOUNT(<field>)=1,GETFIELDSELECTION(<field>),NULL())

shinnickr
Creator II
Creator II
Author

Ah, I apologize.  I meant to say one DISTINCT value in it.  It could have 10-20 values, but all of them would be "1)....."

tamilarasu
Champion
Champion

Hi Ryan,

I am not sure I understand your question. But try his

If(Count(DISTINCT [Rule Description] ) =1,1,0)

shinnickr
Creator II
Creator II
Author

Yeah I'm sorry, I just don't really know how to explain it very well.


I have 13 different values in [Rule Description] and 15 different columns that I want to dynamically show/hide based on the value of [Rule Description].  I have it working with my earlier code that if people actually filter upon a single [Rule Description], it shows only the columns I want to show.  The problem is that end users might not filter solely on [Rule Description].  So if someone filters on [Cost Center], the columns don't hide because they are looking at the [Rule Description] filter, not any others.  What I want to happen is that if someone filters on anything other than [Rule Description] and the resulting table only has DISTINCT [Rule Description]s, to hide the columns as if they'd filtered on [Rule Description] and nothing else.

shinnickr
Creator II
Creator II
Author

So I actually think you're on the right track, and what I need to do is just combine it with set analysis so that the type of rule is taken into account.

So something like:

if(count({$<wildmatch(GetFieldSelections([Rule Description]), '*1)*')>} DISTINCT [Rule Description] = 1, 1, 0))

But I can't get the syntax right.

But I also can't use GetFieldSelections because nothing is actually selected for [Rule Description].....Argh

tamilarasu
Champion
Champion

Got it. Something like this.

If(GetSelectedCount([Cost Center])>0 and GetSelectedCount([Rule Description])=0 and Count(Distinct [Rule Description]) =1,1,0)

tamilarasu
Champion
Champion

Ryan, I am not why you are hard-coding the specific value '*1)*.  You said that you have 13 distinct values, so this will work for only the specific value and not others. I have to catch my cab so sorry if there is delay in my response (But I will surely reply within 1 hr).