Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Pigi21096
Contributor
Contributor

hide column in pivot table with button

Hi everyone!I could really use some help!

I have a pivot table with some accounts as dimensions and two comlumns year and month. I have been trying to find a way so i can hide one or more columns from the pivot table with a button but it does not work so far. I want the user to be able to choose one or more years from the pivot chart and then press the button and the selected years to be hidden and all the others to be shown exactly as before. I have tried "Select excluded" as an action for the button, but the result is that it shows only the data referring to this year, which is the opposite from what i want. I want to choose one year and the according column to be hidden.

If anyone could help me I would so much appreciate it. Thanks in advance!

Labels (4)
4 Replies
GaryGiles
Specialist
Specialist

If you are trying to hide a column once values have been filtered that column, try:

if(GetSelectedCount([Year])>0,0,1)

in the "Show column if" expression for the dimension.  When a user selects one or more values from the field [Year] and clicks the check mark to accept, the column will be hidden.  If the filter on [Year] is cleared, [Year] will return to the pivot.

GaryGiles
Specialist
Specialist

Your other option is to create a variable, vShowHideYear and give it an initial value of 1.

In the "Show column if" expression for the Year dimension, use:

$(vShowHideYear)

Create a button with an action of "Set variable value" for the variable vShowHideYear

For the value expression, use:

=if($(vShowHideYear)=1,0,1)

And under Appearance->Label, use:

=if($(vShowHideYear)=1,'Hide Year','Show Year')

Hope that helps.

Pigi21096
Contributor
Contributor
Author

Gary thank you so so much for taking the time to response! I really appreciate it!

I have tried both of your solutions. The first one gives an error in the column's expression. The second one kinda works. Kinda goes to this: if I select the year the column dissapears indeed but the monthly data inside the year column stay the same.  I enclose 2 pictures below so you can underastand what I am talking about. I want those data to disappear too with the year choice. 

Any ideas maybe? I know I am asking too much but it's important. Thanks again!

GaryGiles
Specialist
Specialist

I'm not following what behavior you are looking for.  What do you mean by "data to disappear too with the year choice"?

When you filter on a year in the pivot and the Year field is hidden, the remaining data will be months for the selected Year.

Are you asking that when the year is selected and hidden, the data should display everything except the year that is selected??  Or is it something else?