Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excel/PivotTable: Is there any way to prevent the cells from moving when I filter information?

My current pivot table contains 4 columns: time in Column A, then Zone 1 in Column B, Zone 2 in Column C, and Zone 3 in Column D.

Is there any way to "lock" the columns, e.g. if I apply filter by Zone and only select Zone 3, Zone 3 will stay in Column D?

Currently, if I filter by Zone and only select Zone 3, Zone 1 and Zone 2's column disappear and Zone 3 will then be in Column B.

Thanks for any help you can provide.

like image 556
FionaS Avatar asked Aug 16 '13 16:08

FionaS


People also ask

How do you stop cells from moving when filtering?

Select the cell below the rows and to the right of the columns you want to keep visible when you scroll. Select View > Freeze Panes > Freeze Panes.

How do I lock a filter in a pivot table?

To do that: Highlight the entire worksheet first. CTRL+1> deselect locked on Protection Tab > then highlight the cell you want locked > then select locked for that cell only on Protection Tab > Then Review> Protect Sheet> and so on. You must log in or register to reply here.


1 Answers

I'm going to say "No". Pivot tables are a world to themselves inside of Excel.

You may have noticed that if you do something that expands them into surrounding data, they don't shift that data, they just warn you. Similarly, if you have formulas that refer to certain columns in a pivot table, filtering the pivot table as you've done doesn't adjust the cell reference as it does when you add or delete regular columns. I assume this is the type of issue you're seeing.

If so, consider using the GetPivotData function, which allows you to refer to pivot table columns.

Below I've shown how this could work with a simple table. The GetPivotData formula uses a variable (an added bonus!) in cell F1. In this case it gives you the overall total for fiona:

=GETPIVOTDATA("value",$E$4,"name",F1)

enter image description here

Note that when I filter to just "fiona" it still works:

enter image description here

Note that you can make the formula as specific as the data in the pivot table. Here I get the sales for doug on Thursday. (I could use variables for both "doug" and "Thursday" here as well:

=GETPIVOTDATA("value",$E$4,"day","Thursday","name","doug")

The easiest way to create a GetPivotData formula is to type "=" in a cell and then click in the pivot table cell you are interested in. You can then edit from there.

Here's a great Contextures GetPivotData tutorial.

like image 87
Doug Glancy Avatar answered Oct 27 '22 10:10

Doug Glancy