Rolling 12 months in Pivot Table automated

jmartell

Board Regular
Joined
Jun 25, 2004
Messages
54
Hi There,

I have a pivot table and each month I add the new month. I want to drop the last month so I maintain a rolling 12 weeks. I do not want to have to go into the pivot and relink my chart data. Is there a way to add a field into my data that would automate and refresh just the current rolling months?

Thanks,
J9 :o
 
How about a formula in your data that gives a "Show" or "Hide" result depending on the dates?

Such as; =if(A5>toady()-84,"Show","Hide")

Then build the pivot with the Show/Hide data in a Page setting but only "Show" displayed.

As time moves etc the "Show" data will roll over as you want. If your data is simpler (ie no formulas) a macro could insert the formula for you.

Good luck,

Bruce
 
Upvote 0
this can be done without the addition of an extra column. the technique uses a dynamic named range - search the board for a variety of ways of setting one up. post back with info on where your data is, what you need selected etc if you can't get iot working.
 
Upvote 0
The Show Hide method may work although I can not get it to work. For example 38047 may be March 01 and 38670 may be Feb 03. I need help with a formula that will extract current month and year, otherwise it gives me Sept 03 as my current month when Aug 04 is actually my current date for my fiscal data.

Thanks for any help.

I did try the dynamic range but don't understand it.

J9
 
Upvote 0
My data is in Column B and always adds each month by Row only. The field is called Time and it comes from a CVS file and the Excel number format is i.e 38706 = Feb 03.

J9
 
Upvote 0
PS. My total data sheet is in A1 to L47080. I have several charts that need to be linked to the pivot but need the pivot to roll only the last 13 current months. Since the Excel number format in the date is Year, Month and Day. I can not figure out how to write a formula to do this. I tried your dynamic range idea and got as far as =offset($A$1,0,0,Counta($A:$A)),Counta($1:$1) but this gives me the whole ball of wax!

Thanks again.
 
Upvote 0
say I had the followeing:
Book1
BCDE
1DateValue
21/01/20011
31/02/20012
41/03/20013
51/04/20014
61/05/20015
71/06/20016
81/07/20017
91/08/20018
101/09/20019
111/10/200110
121/11/200111
131/12/200112
141/01/200213
151/02/200214
161/03/200215
Sheet1


...& wanted to set a range to cover only the last 12 entries. Defined ranges are st up using einsert | name | define. Define a name pivot_range to equal:

=OFFSET(Sheet1!$B$1,COUNTA(Sheet1!$B:$B)-12,0,12,2)

Bit-by-bit:

=OFFSET(Sheet1!$B$1

- so we're starting from B1

=OFFSET(Sheet1!$B$1,COUNTA(Sheet1!$B:$B)

- & we're going down as many many rows as are counted to have something in them - which should be the end of the list if there's no gaps in the data

=OFFSET(Sheet1!$B$1,COUNTA(Sheet1!$B:$B)-12

- then taking 12 off to move back up the list 12 rows to get the start point

=OFFSET(Sheet1!$B$1,COUNTA(Sheet1!$B:$B)-12,0,

- not offsetting any columns

=OFFSET(Sheet1!$B$1,COUNTA(Sheet1!$B:$B)-12,0,12,

- and the range we want is 12 rows "high" from the start point established above

=OFFSET(Sheet1!$B$1,COUNTA(Sheet1!$B:$B)-12,0,12,2)

- & my example has 2 columns, so we want the range 2 columns wide.

Set up a similar example yourself, to get the hang of it. check the range defined by hitting ctrl + G & going to pivot_range. Add some data to the bottom of the list & do it again.

To use this in a pivot, just set the pivot's target range as pivot_range in step 2 of the pivot wizard.
 
Upvote 0
Thank you, this is extremely helpful and I am starting to understand. Although I have two hurdles. 1) my data is not sorted on date when I get it and 2) I have several entries for each month. So my Time column looks something like this although much larger. So I need a formula that will look through everything and say: August 04 is most current...in the pivot table give me most current month by year and 12 months previous!

TIMEPER
Mar-04
Mar-04
Oct-02
Oct-02
Oct-02
Dec-01
Dec-01
Dec-01
Aug-01
Aug-01
Jul-01
Jul-01
Jun-01
Jun-01
Aug-03
Aug-04
Aug-04
Aug-04
Aug-04
Aug-04
Aug-04
Aug-04
Aug-04
Aug-04
Aug-04
Aug-04
Aug-04
Aug-04
Aug-04
Aug-03
Aug-03
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top