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"))
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Do you want 5 separate results, or one total for the last 5 weeks?
 
Upvote 0
I would like a result for each week, so the table would look like the following:

[TABLE="width: 500"]
<tbody>[TR]
[TD]Name[/TD]
[TD]Week 17[/TD]
[TD]Week 18[/TD]
[TD]Week 19[/TD]
[TD]Week 20[/TD]
[TD]Week 21[/TD]
[/TR]
[TR]
[TD]Bill[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Phil[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

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.
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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