I have a pivot table that I am trying to reference using a date as part of the lookup. The pivot table data can be grouped by day, week or month (there is a little VBA that controls this) However, I cannot seem to create a GETPIVOTDATA function that will work with all three groupings. - When grouped by day, GETPIVOTDATA seems to want the day of the year (1-365), it won't accept a date.
=GETTPIVOTDATA(value, pt, "Date", 184)
- When grouped by week, it will accept a date and return the week that the date falls in
=GETTPIVOTDATA(value, pt, "Date", Date(2012, 08, 22))
- When grouped by month, it seems to want the month of the year (1-12)
=GETTPIVOTDATA(value, pt, "Date", 11)
Is there anyway to use a date with all three groupings? Bear in mind that the groupings will change but the formula won't so the same formula has to work with any grouping.
The alternatives are using an IF statement and date manipulation or using VBA whenever I change the groupings. However, I feel that the should be a way to just use the date, regardless of the grouping.