Suppose the value of cell A1 is total sales $ at the Los Angeles location, year to date. The value is pulled from a pivot table on a different sheet. The formula for A1 is:
=SUM(GETPIVOTDATA("Amount",'Transactions(Pivot)'!$A$75,"Location","Los Angeles","Months",{7,8,9,10,11,12}))
Currently, every month when I run this report I need to manually update the month arrays in the formulas; for example next month I will need to manually update {7,8,9,10,11,12} to {7,8,9,10,11,12,1}. There are many cells and this is a very tedious task.
My question is how can I automate the task of updating the month array in the GETPIVOTTABLE formula?
What I've attempted with no success: I set up a 2-column lookup table on a different sheet where column A is the current month and column B contains the month array value to be used in the GETPIVOTTABLE formula. For example:
7 {7}
8 {7,8}
9 {7,8,9}
etc...
Then I tried updating my GETPIVOTTABLE formula to use a VLOOKUP to get the month array:
=SUM(GETPIVOTDATA("Amount",'Transactions(Pivot)'!$A$75,"Location","Los Angeles","Months",VLOOKUP($B$2,$L$9:$M$20,2,FALSE))
But it didn't work - I get a #REF! error.
Thanks in advance for your help.