GetPivotData for the past 5 weeks

skoorBmaS

New Member
Joined
Feb 5, 2016
Messages
34
I am currently using a pivot table which shows information regarding how much time an employee has worked, which is separated by week number. I would ideally like a GETPIVOTDATA formula to take this information and place it onto a dashboard screen, however only show the data from the past 5 weeks.

To get a week number, I am using a cell which has =TODAY() and then another one which uses =WEEKNUM() to provide a week number for that day. However in the GETPIVOTDATA formula, I can only get it to get data for a certain week (e.g. 21, rather than 21, 20, 19, 18 and 17). By using this method, I hope that the pivot data which is being extracted will automatically update based on today's date.

Does anyone know how to do this? The current formula which I am using is as below

Code:
=(GETPIVOTDATA("Hrs+Travel",Pivots!$AA$2,"Week",21,"Name","Bill"))
 

Some videos you may like

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
36,151
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
Do you want 5 separate results, or one total for the last 5 weeks?
 

skoorBmaS

New Member
Joined
Feb 5, 2016
Messages
34
I would like a result for each week, so the table would look like the following:

NameWeek 17Week 18Week 19Week 20Week 21
Bill
Phil

<tbody>
</tbody>

So then when the next week comes, the values at the top of the table shall automatically update to show this week as the value on the far right.
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
36,151
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
Then I'd suggest that you just enter numbers into those header cells and give them a custom number format of "Week "0 so that they display as shown above. You can then just refer to them in the GETPIVOTDATA formula - for example:

=GETPIVOTDATA("Hrs+Travel",Pivots!$AA$2,"Week",B$1,"Name",$A2))

where B1 has the week number and A2 has the name.
 

Watch MrExcel Video

Forum statistics

Threads
1,123,310
Messages
5,600,879
Members
414,413
Latest member
Sinbin

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
Top