+ Reply to Thread
Results 1 to 42 of 42

Modify GetPivotTable formula for a Specific Date or Date Range?

  1. #1
    Registered User
    Join Date
    10-08-2013
    Location
    United States, North Ameriac
    MS-Off Ver
    Excel 2010, Excel 2007, Excel 2013
    Posts
    58

    Question Modify GetPivotTable formula for a Specific Date or Date Range?

    I've been looking around for a solution for this, haven't found exactly what I am needing. Is there a way to modify the GetPivotTable formula to show a specific date?

    My formula looks like this

    Please Login or Register  to view this content.
    where 20131101 is the date to be modified

    Can something be embedded like today() or today()-1, etc? Ideally, I would like to sub in different operator IDs (the Operator ID in the above formula is 555) and get data for that operator on a specific date, and maybe eventually a date range.

    Working with a large spreadsheet, so this solution or something similar would be a great help.

    Thanks for any help!

  2. #2
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Modify GetPivotTable formula for a Specific Date or Date Range?

    You should be able to do something like:


    =GETPIVOTDATA("[Measures].[% Oper KPI A]",'Data Cube 1'!$A$3,"[Operator].[Operator]","[Operator].[Operator].[Operator].&[555]","[Company Name Date].[Company Name Date]","[Company Name Date].[Company Name Date].[Date].&["&text(today(),"yyyymmdd")&"]")
    Remember what the dormouse said
    Feed your head

  3. #3
    Registered User
    Join Date
    10-08-2013
    Location
    United States, North Ameriac
    MS-Off Ver
    Excel 2010, Excel 2007, Excel 2013
    Posts
    58

    Re: Modify GetPivotTable formula for a Specific Date or Date Range?

    Thanks, Rory:

    I tried that but am getting a ref error. I tried "insert function" as well, and it doesn't seem to be working.

    I'm working with limited access to the pivot table currently. I think that the table is not fully displaying all the
    data for all the available dates and that's why I am getting the ref error? Or will this work even if the data is not visible in the pivot table as long as there is a working connection to the server? I will try this again when I have full access.

    Thanks, again.

  4. #4
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Modify GetPivotTable formula for a Specific Date or Date Range?

    You will get a #REF error if the data is not visible in the pivot.

  5. #5
    Registered User
    Join Date
    10-08-2013
    Location
    United States, North Ameriac
    MS-Off Ver
    Excel 2010, Excel 2007, Excel 2013
    Posts
    58

    Re: Modify GetPivotTable formula for a Specific Date or Date Range?

    Rory (and anyone that can help):

    I've tried the formula and ensured that the date and data are visible in the pivot table that
    I am trying to display data from. I still get a ref error. If I do a simple =getpivottable function
    and click on the cell data on the worksheet that I want to retrieve the info from, it works. But since
    I have over 300 records to do this for, with more to come, I was hoping I could copy this formula
    for each and eventually make this a macro.

    Is there another function I should try or reference material to look into? I've looked at contextures
    HTML Code: 
    But I am trying to get away from putting the actual
    date in.

    Thank you

  6. #6
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Modify GetPivotTable formula for a Specific Date or Date Range?

    did you try the formula exactly as Rory posted or did you change it at all?
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  7. #7
    Registered User
    Join Date
    10-08-2013
    Location
    United States, North Ameriac
    MS-Off Ver
    Excel 2010, Excel 2007, Excel 2013
    Posts
    58

    Re: Modify GetPivotTable formula for a Specific Date or Date Range?

    @JosephP

    I kept the syntax the same, but had to modify the "Company Name" portion. I used that generic
    term for sensitive info.

    Update: I altered the today() portion to today()-1 because the server hasn't updated totals for today (I am thinking).
    When I implemented that, I got the data to populate for yesterday's date. This is optimal because of the nature of the
    KPI's I am analyzing. So, thank you Rory (and JosephP) for taking time out to help!

    And I am wondering, what is the syntax for getting totals for week-to-date and period/month-to-date? I've looked around and didn't see anything of this sort (just saw things like =(NOW()+1)+(WEEKDAY(NOW())=6)*2+(WEEKDAY(NOW())=7), would this work or is it that I would have to point my cells to corresponding subtotals on the source data sheet?

    Thanks!

  8. #8
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Modify GetPivotTable formula for a Specific Date or Date Range?

    If the individual day totals are present in the pivot table, you should be able to make use of the fact that dates are just numbers in Excel so you can use the row function to create an array of dates. Say your start and end dates are in A1 and A2:


    =SUMPRODUCT(IFERROR(GETPIVOTDATA("[Measures].[% Oper KPI A]",'Data Cube 1'!$A$3,"[Operator].[Operator]","[Operator].[Operator].[Operator].&[555]","[Company Name Date].[Company Name Date]","[Company Name Date].[Company Name Date].[Date].&["&text(ROW(INDIRECT(A1&":"&A2))),"yyyymmdd")&"]"),0))

    Untested as I'm on an iPad.

  9. #9
    Registered User
    Join Date
    10-08-2013
    Location
    United States, North Ameriac
    MS-Off Ver
    Excel 2010, Excel 2007, Excel 2013
    Posts
    58

    Re: Modify GetPivotTable formula for a Specific Date or Date Range?

    Thanks Rory for the response!

    I tried the formula you suggested and got an invalid argument error. I corrected
    this by omitting a parenthesis (see bold text)

    Please Login or Register  to view this content.
    However, I also change the "A1" and "A2" because the week start date is in E16 and the end date is in E22 with all the dates in between (i.e. E16=2013-10-28, E17=2013-10-29, E18=2013-10-30, E19=2013-10-31, E20=2013-11-01, E21=2013-11-02, E22=2013-11-03)

    Well, all the cells I tested this out on are returning the iferror 0. Even the ones that I know have data in them. What have I goofed up on?

    Thanks!

  10. #10
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Modify GetPivotTable formula for a Specific Date or Date Range?

    are the values in E16 and E22 stored as real dates?

  11. #11
    Registered User
    Join Date
    10-08-2013
    Location
    United States, North Ameriac
    MS-Off Ver
    Excel 2010, Excel 2007, Excel 2013
    Posts
    58

    Re: Modify GetPivotTable formula for a Specific Date or Date Range?

    @JosephP: this is what is displayed in the cells

    E16: 2013-10-28 00:00:00
    E22: 2013-11-03 00:00:00.

    Is that what you are asking? This is from my pivot table (from a cube) sheet.

    Thanks!

  12. #12
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Modify GetPivotTable formula for a Specific Date or Date Range?

    if you change the cell format does the displayed value change?

  13. #13
    Registered User
    Join Date
    10-08-2013
    Location
    United States, North Ameriac
    MS-Off Ver
    Excel 2010, Excel 2007, Excel 2013
    Posts
    58

    Re: Modify GetPivotTable formula for a Specific Date or Date Range?

    Just checked. No, it doesn't.

  14. #14
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Modify GetPivotTable formula for a Specific Date or Date Range?

    Then they aren't real dates. You need real dates for the formula to work.

  15. #15
    Registered User
    Join Date
    10-08-2013
    Location
    United States, North Ameriac
    MS-Off Ver
    Excel 2010, Excel 2007, Excel 2013
    Posts
    58

    Re: Modify GetPivotTable formula for a Specific Date or Date Range?

    Possibly (really, really) stupid question: but is there a way to find the "real" dates on this pivot table?

  16. #16
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Modify GetPivotTable formula for a Specific Date or Date Range?

    are E16 and E22 in your pivot table? those formats don't seem to tally with your original question

  17. #17
    Registered User
    Join Date
    10-08-2013
    Location
    United States, North Ameriac
    MS-Off Ver
    Excel 2010, Excel 2007, Excel 2013
    Posts
    58

    Re: Modify GetPivotTable formula for a Specific Date or Date Range?

    I've attached a screenshot example of what my pivot table looks like. It's pulled from a cube.
    I am trying to get the current week and current month/period to automatically populate (using a formula-hopefully!) in another worksheet, like I was able to with the "today" function (thanks to you and Rory!)
    Attached Files Attached Files

  18. #18
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Modify GetPivotTable formula for a Specific Date or Date Range?

    if you enter = in a blank cell and then select F22 what is the getpivotdata formula that is created?

  19. #19
    Registered User
    Join Date
    10-08-2013
    Location
    United States, North Ameriac
    MS-Off Ver
    Excel 2010, Excel 2007, Excel 2013
    Posts
    58

    Re: Modify GetPivotTable formula for a Specific Date or Date Range?

    =GETPIVOTDATA("[Measures].[% Oper KPI A]",$A$3,"[Operator].[Operator]","[Operator].[Operator].[Operator].&[4323]","[Company Name Date].[Company Name Date]","[Company Name Date].[Gompany Name Date].[Date].&[20131103]")

  20. #20
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Modify GetPivotTable formula for a Specific Date or Date Range?

    were you array-entering Rory's formula using Ctrl+Shift+Enter?

  21. #21
    Registered User
    Join Date
    10-08-2013
    Location
    United States, North Ameriac
    MS-Off Ver
    Excel 2010, Excel 2007, Excel 2013
    Posts
    58

    Re: Modify GetPivotTable formula for a Specific Date or Date Range?

    I tried it both ways (CSE and without CSE) I get an Excel formula error and when I hit "ok", this is highlighted (see bold):

    =SUMPRODUCT(IFERROR(GETPIVOTDATA("[Measures].[% Oper KPI A]'Data Cube 1'!$A$3,"[Operator].[Operator]","[Operator].[Operator].[Operator].&[555]","[Company Name Date].[Company Name Date]","[Company Name Date].[Company Name Date].[Date].&["&text(ROW(INDIRECT(A1&":"&A2))),"yyyymmdd")&"]"),0))

  22. #22
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Modify GetPivotTable formula for a Specific Date or Date Range?

    It needs array entry (I should have said that). It looks as though you are missing some quotes and a comma:

    =SUMPRODUCT(IFERROR(GETPIVOTDATA("[Measures].[% Oper KPI A]",'Data Cube 1'!$A$3,"[Operator].[Operator]","[Operator].[Operator].[Operator].&[555]","[Company Name Date].[Company Name Date]","[Company Name Date].[Company Name Date].[Date].&["&text(ROW(INDIRECT(A1&":"&A2))),"yyyymmdd")&"]"),0))

  23. #23
    Registered User
    Join Date
    10-08-2013
    Location
    United States, North Ameriac
    MS-Off Ver
    Excel 2010, Excel 2007, Excel 2013
    Posts
    58

    Re: Modify GetPivotTable formula for a Specific Date or Date Range?

    Rory and JosephP:

    It's returning the iferror 0's again for employees that I know there should be actual data. I'm poking around with it, but so far it's a no go.

  24. #24
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Modify GetPivotTable formula for a Specific Date or Date Range?

    can you post a sample workbook with a real pivot in it?

  25. #25
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Modify GetPivotTable formula for a Specific Date or Date Range?

    If you do, assuming it's still sourcing from a cube, please make sure the pivot is not set to refresh on open.

  26. #26
    Registered User
    Join Date
    10-08-2013
    Location
    United States, North Ameriac
    MS-Off Ver
    Excel 2010, Excel 2007, Excel 2013
    Posts
    58

    Re: Modify GetPivotTable formula for a Specific Date or Date Range?

    I will try to, but I'm afraid it would take a lot of time to hide sensitive data (and you've seen from my previous posts what a beginner I am). I checked the connection properties and it is not set to refresh data upon opening, so that's good.

    I truly appreciate you both helping me with this! I have been frustrated and working under a deadline and this is the "last piece" before the next phase.

  27. #27
    Registered User
    Join Date
    10-08-2013
    Location
    United States, North Ameriac
    MS-Off Ver
    Excel 2010, Excel 2007, Excel 2013
    Posts
    58

    Re: Modify GetPivotTable formula for a Specific Date or Date Range?

    Okay, here goes.

    The first sheet is the workbook. The second is the datasheet I am trying to nail down with formulas for yesterday, week-to-date, and period/month-to-date.

    Thanks!
    Attached Files Attached Files
    Last edited by onemoremile; 11-06-2013 at 05:23 PM.

  28. #28
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Modify GetPivotTable formula for a Specific Date or Date Range?

    it works here. I entered 9/30/2013 in D4 and 10/6/2013 in D5 on the summary sheet and then in D2

    =SUMPRODUCT(IFERROR(GETPIVOTDATA("[Measures].[% Oper Disp Pymt 52W+EZ]",'Data Cube 1'!$A$1,"[Company Date].[Company Date]","[Company Date].[Company Date].[Date].&["&TEXT(ROW(INDIRECT(D4&":"&D5)),"yyyymmdd")&"]","[Operator].[Operator]","[Operator].[Operator].[Operator].&[4752]"),0))

    array-entered to return 99.4
    Last edited by JosephP; 11-06-2013 at 04:45 PM.

  29. #29
    Registered User
    Join Date
    10-08-2013
    Location
    United States, North Ameriac
    MS-Off Ver
    Excel 2010, Excel 2007, Excel 2013
    Posts
    58

    Re: Modify GetPivotTable formula for a Specific Date or Date Range?

    @JosephP (thanks a ton):

    If I understand this correctly, I need to specify/create the start and end dates somewhere on my summary sheet? That's the
    only missing piece? Or do I point to the specific dates already listed on the pivot table sheet?

  30. #30
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Modify GetPivotTable formula for a Specific Date or Date Range?

    you don't need-you could hard code the dates in the formula if you want-to but it probably makes maintenance easier

  31. #31
    Registered User
    Join Date
    10-08-2013
    Location
    United States, North Ameriac
    MS-Off Ver
    Excel 2010, Excel 2007, Excel 2013
    Posts
    58

    Re: Modify GetPivotTable formula for a Specific Date or Date Range?

    Could you show an example of hardcoding the dates in the formula? That would be ideal since the syntax/structure of this formula will have to be applied to many, many records.

  32. #32
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Modify GetPivotTable formula for a Specific Date or Date Range?

    I'm not real clear on why you would want to do that but just replace the cell references with DATE(2013,9,30) for example or use a literal number value (which you can find by entering a date in a cell and then formatting it as General)

  33. #33
    Registered User
    Join Date
    10-08-2013
    Location
    United States, North Ameriac
    MS-Off Ver
    Excel 2010, Excel 2007, Excel 2013
    Posts
    58

    Re: Modify GetPivotTable formula for a Specific Date or Date Range?

    Thank you, JosephP and Rory! Your help is greatly appreciated! I think I am
    understanding enough about this function that I can apply it to the month/period
    date range as well.

    I really appreciate you both walking me through the steps and answering my questions!

  34. #34
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Modify GetPivotTable formula for a Specific Date or Date Range?

    you're welcome :-)

    please don't forget to mark the thread solved (click the 'thread tools' link at the top, then 'mark solved')

  35. #35
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Modify GetPivotTable formula for a Specific Date or Date Range?

    Glad to help.

    Thanks for the backup, Josie.

  36. #36
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Modify GetPivotTable formula for a Specific Date or Date Range?

    any time hon ;-P

  37. #37
    Registered User
    Join Date
    10-08-2013
    Location
    United States, North Ameriac
    MS-Off Ver
    Excel 2010, Excel 2007, Excel 2013
    Posts
    58

    Re: Modify GetPivotTable formula for a Specific Date or Date Range?

    Hi again, Rory and JosephP (and whoever can help!)

    How would I modify this formula to give me the average of these values over the specific time period (week, or month, etc)? Would I incorporate averageif? If so, where? When I attempted to, I got "too few arguments" error.

    =SUMPRODUCT(IFERROR(GETPIVOTDATA("[Measures].[KPI A]",'Data Cube 1'!$A$3,"[Company Date].[Company Date]","[Company Date].[Company Date].[Date].&["&TEXT(ROW(INDIRECT(AB5&":"&AB6)),"yyyymmdd")&"]","[Operator].[Operator]","[Operator].[Operator].[Operator].&[555]"),0)

    Thank you very much for any help anyone can give!

  38. #38
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Modify GetPivotTable formula for a Specific Date or Date Range?

    perhaps simply

    =AVERAGE(IFERROR(GETPIVOTDATA("[Measures].[KPI A]",'Data Cube 1'!$A$3,"[Company Date].[Company Date]","[Company Date].[Company Date].[Date].&["&TEXT(ROW(INDIRECT(AB5&":"&AB6)),"yyyymmdd")&"]","[Operator].[Operator]","[Operator].[Operator].[Operator].&[555]"),"")

  39. #39
    Registered User
    Join Date
    10-08-2013
    Location
    United States, North Ameriac
    MS-Off Ver
    Excel 2010, Excel 2007, Excel 2013
    Posts
    58

    Re: Modify GetPivotTable formula for a Specific Date or Date Range?

    @JosephP,

    Thanks so much for responding! So far, it's not working (surprise, surprise) I get a value error. I am sure it's something I've done or didn't do. I've done a simple average on some pivot table data and that seems to work with no issue. It's just using this "getpivotdata" syntax for the specified date range that seems to make things dicey. I'm using Excel 2013 if that gives any extra insight.

    Thanks, again

  40. #40
    Registered User
    Join Date
    10-08-2013
    Location
    United States, North Ameriac
    MS-Off Ver
    Excel 2010, Excel 2007, Excel 2013
    Posts
    58

    Re: Modify GetPivotTable formula for a Specific Date or Date Range?

    Uploading sample data.

    This has 3 tabs: Pivot table, data sheet, results sheet.

    The pivot table has some numbers for KPIs and I would like
    to get the average for date ranges (week and month) on the "results" tab.
    The date ranges are detailed on H1-H7 of the results sheet


    Hope this clarifies!

    Thanks!
    Last edited by onemoremile; 11-21-2013 at 05:44 PM.

  41. #41
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Modify GetPivotTable formula for a Specific Date or Date Range?

    not much resemblance between that sheet and your question but
    =AVERAGE(IFERROR((GETPIVOTDATA("Sum of KPI A",'Pivot Table'!$A$3,"Day",TEXT(ROW(INDIRECT(H3&":"&H4)),"yyyy-mm-dd hh:mm:ss"))&"")+0,""))
    must be array-entered with Ctrl+Shift+Enter

  42. #42
    Registered User
    Join Date
    10-08-2013
    Location
    United States, North Ameriac
    MS-Off Ver
    Excel 2010, Excel 2007, Excel 2013
    Posts
    58

    Re: Modify GetPivotTable formula for a Specific Date or Date Range?

    @JosephP:

    The good news is, I finally got the formula to work. The challenge I now have is that I have just been informed that the data
    that is needed is not a "true" average. Meaning that there are behind the scene calculations done on the server (I'm guessing).

    I think I need to close this topic as solved and do a search or open another topic on just retrieving the data using some kind of modification of this formula:

    =GETPIVOTDATA("[Measures].[KPI A]",'Data Cube'!$A$3,"[Operator].[Operator]","[Operator].[Operator].[Operator].&[555]","[Date].[Date]","[Date].[Date].[Week].&[2013]&[11]&[3]")

    where &[2013]&[11]&[3]") can be modified depending on what the current date is. At this point, I just need this worksheet to refresh with the current data (week-to-date, period-to-date) for the KPIs that are displayed in the pivot table from the cube (if you have any ideas or insight, please feel free to let me know.)

    I really appreciate your help (and have starred you accordingly.)

    Thanks again

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 02-05-2013, 09:14 AM
  2. Replies: 2
    Last Post: 12-31-2012, 12:47 PM
  3. [SOLVED] Match date range reffering to a specific date
    By Ramzes in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-02-2010, 09:22 AM
  4. Formula for determining if two date columns fall within specific date range
    By Igottabeme in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-20-2006, 09:55 PM
  5. Replies: 1
    Last Post: 04-20-2006, 05:10 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1