+ Reply to Thread
Results 1 to 9 of 9

Getpivotdata formula with two variables (month and country)

  1. #1
    Registered User
    Join Date
    11-14-2010
    Location
    Wales
    MS-Off Ver
    Excel 2000
    Posts
    28

    Question Getpivotdata formula with two variables (month and country)

    Hi guys

    I am really stuck and I would really appreciate your help with this.

    I've attached a sample file to this post to demonstrate what I am trying to do.
    I have a pivot table which is showing some data by country and by month.

    I'd really like to use the slicer and a Getpivotdata formula to pull out the relevant country information, but based on the current month we are in.
    You will see that I have added in a formula in cell A2 to give me the current month (July).

    I have highlighted cell E10 in yellow as this is where I would like to add the formula.

    So if the slicer was selected for Australia the yellow box should show: 100
    If France was selected in the slicer, then the yellow box should show 200, and for US it should show 300.

    Does anyone know the formula to do this. I have gone round in circles and just cannot get it work :-(
    I'm a novice with Pivot tables and this type of formula, so any help is very much appreciated :-)

    Thanks
    Debbie
    Attached Files Attached Files

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,025

    Re: Getpivotdata formula with two variables (month and country)

    Try this:

    =GETPIVOTDATA("Traffic",$A$5)
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  3. #3
    Registered User
    Join Date
    11-14-2010
    Location
    Wales
    MS-Off Ver
    Excel 2000
    Posts
    28

    Re: Getpivotdata formula with two variables (month and country)

    Hi Glenn

    Thanks for replying :-)

    That formula is great, but it only gives me the total for that country. I need it to return the value for the selected country and only the month we are currently in. So in this example the formula I have set in cell A2 gives us the current month (July).
    Do you know how to reference the cell containing the current month in the Getpivotdata formula? I need the value to change automatically each month without any manual interference.

    So, if I selected the slicer of Australia, the value it should return is 100.

    Thanks
    Debbie

  4. #4
    Forum Contributor
    Join Date
    11-27-2009
    Location
    Austin, Texas
    MS-Off Ver
    Excel 2013 & 2016
    Posts
    409

    Re: Getpivotdata formula with two variables (month and country)

    Hi Hypnopoison,

    I have got you this far with this formula
    In cell A2 for the month, define the cell name as Mth

    Then

    use formula as =GETPIVOTDATA("Traffic",$A$5,"Country","Australia","MonthName",Mth)

    But I am not too sure how to get the Country name to change with the slicer selection.

    Thanks
    ==========
    Bigroo1958
    Austin, Texas
    ==========

  5. #5
    Forum Contributor
    Join Date
    11-27-2009
    Location
    Austin, Texas
    MS-Off Ver
    Excel 2013 & 2016
    Posts
    409

    Re: Getpivotdata formula with two variables (month and country)

    Here's another way to show your data based on a slicer selection.

    Thanks
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    11-14-2010
    Location
    Wales
    MS-Off Ver
    Excel 2000
    Posts
    28

    Re: Getpivotdata formula with two variables (month and country)

    Hi, thanks for your reply and for the file. That solution is so close. I was wondering if a subtotal formula would work? So subtotal the values (as that responds to the slicer), and then some how use the getpivotdata formula with it to just extract the current month ... would that work (although I have not idea how to link the two)?

    I've added the subtotal formula into the green box.

    So close to solving this, any help is much appreciated :-)
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    11-14-2010
    Location
    Wales
    MS-Off Ver
    Excel 2000
    Posts
    28

    Re: Getpivotdata formula with two variables (month and country)

    Actually, I've changed the way the date is extracted so that it now shows as an actual date, and not just the text of the month name. Not sure if that'll help.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    11-14-2010
    Location
    Wales
    MS-Off Ver
    Excel 2000
    Posts
    28
    Also just wondering if a double slicer would do the job? I'd rather we could handle it more dynamically without too much manual intervention - but I'll take any suggestions right now :O)

  9. #9
    Forum Contributor
    Join Date
    11-27-2009
    Location
    Austin, Texas
    MS-Off Ver
    Excel 2013 & 2016
    Posts
    409

    Re: Getpivotdata formula with two variables (month and country)

    Try this link, there is an example spreadsheet to download and pull apart.

    http://www.myonlinetraininghub.com/u...on-in-formulas

    Also, please update the spelling of February in your pivot table data, you have to spellings, this is cause slight issues.
    Last edited by bigroo1958; 07-28-2016 at 08:55 PM.

+ 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. GetPivotData - Issues with multiple variables and Grand Totals
    By lewisf182 in forum Excel Charting & Pivots
    Replies: 5
    Last Post: 06-24-2015, 06:22 AM
  2. Country Sales Figures by Month
    By SimonLis in forum Excel General
    Replies: 4
    Last Post: 10-05-2012, 09:51 AM
  3. Replies: 10
    Last Post: 01-04-2012, 10:03 AM
  4. Add ‘country name’ column to worksheet from a list of country codes.
    By Ben Morton in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-02-2009, 09:24 AM
  5. Dragging Month in GetPivotData
    By easycapital in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 06-30-2008, 09:06 AM
  6. getpivotdata with 2 variables
    By shereman in forum Excel General
    Replies: 3
    Last Post: 07-29-2005, 08:05 AM
  7. GETPIVOTDATA to create Purchase in specified month
    By Andri in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 02-20-2005, 12:06 PM

Tags for this Thread

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