+ Reply to Thread
Results 1 to 9 of 9

Pivot table field selection based on selection in other Pivot

  1. #1
    Registered User
    Join Date
    07-03-2019
    Location
    Stockholm, Sweden
    MS-Off Ver
    2013
    Posts
    61

    Pivot table field selection based on selection in other Pivot

    Hi,

    After so much great help from this forum, I try my luck with below question - not sure it's actually doable but if so, someone here will know :-)

    I have an analysis that is based on 3 hidden pivots. 2 of them need to be set to the year I want to analyse (which I solve with a slicer linked to both pivots). Now the third one needs to be set to "previous year". For now, I solve this with a second slicer but I was wondering if there is a way to make that one "linked" somehow as sometimes people forget or select the wrong year. So, can I make a pivot table select a value filter for year based on what is selected for another pivot??

    I guess a macro would help - not very familiar with those though... So any non-macro suggestion would be great. If only doable with macro, anyone can help me with the code?? Working with Windows 10, 64-bit and MS Office Professional Plus 2013 if this is needed...

    Thanks!!
    Wiebke
    Last edited by whahnelt; 10-22-2019 at 03:33 AM.

  2. #2
    Forum Expert PaulM100's Avatar
    Join Date
    10-09-2017
    Location
    UK
    MS-Off Ver
    Office 365
    Posts
    2,108

    Re: Pivot table field selection based on selection in other Pivot

    You could try something else. In a hidden cell add(for my example macro, add it in A1) like =Sheet2!B2-1(Sheet2!B2 being the year cell for those 2 pivots - 2018 in your case)
    And then, right click on worksheet, view code and drop this:
    Please Login or Register  to view this content.
    Make changes as necessary for the portions marked in red
    Click the * to say thanks.

  3. #3
    Registered User
    Join Date
    07-03-2019
    Location
    Stockholm, Sweden
    MS-Off Ver
    2013
    Posts
    61

    Re: Pivot table field selection based on selection in other Pivot

    Thanks a lot for the fast help! I will try this out once this month's reporting is done. If I struggle, I may come back with a question but it seems pretty easy to follow - so a big thanks for that already!

  4. #4
    Registered User
    Join Date
    07-03-2019
    Location
    Stockholm, Sweden
    MS-Off Ver
    2013
    Posts
    61

    Re: Pivot table field selection based on selection in other Pivot

    Reply deleted, not valid anymore. Please see other reply.
    Last edited by whahnelt; 10-21-2019 at 07:54 AM. Reason: Changes in data

  5. #5
    Registered User
    Join Date
    07-03-2019
    Location
    Stockholm, Sweden
    MS-Off Ver
    2013
    Posts
    61

    Re: Pivot table field selection based on selection in other Pivot

    Hi again,

    I now tried and actually got the code to change the selected year in my third pivot. Unfortunately, now all years are selected as soon as I make a change to the year in the first pivot.
    Maybe because the year in the incoming report is stored as text but a number in D2?? If this could be the reason, can that be somehow solved in the code, too?? Changing the quite large incoming report every week would not be a very efficient solution, I'm afraid...

    Also, I had to add a fourth pivot, which also should be updated to the year in D2.

    My worksheet is called "PIVOT", the pivots that should be updated are "PivotDetails_PY" and "PivotSummary_PY". And the year to select for those two pivots is in cell D2.

    Can you help me update the code to make it work??

    Quote Originally Posted by PaulM100 View Post
    You could try something else. In a hidden cell add(for my example macro, add it in A1) like =Sheet2!B2-1(Sheet2!B2 being the year cell for those 2 pivots - 2018 in your case)
    And then, right click on worksheet, view code and drop this:
    Please Login or Register  to view this content.
    Make changes as necessary for the portions marked in red

  6. #6
    Forum Expert PaulM100's Avatar
    Join Date
    10-09-2017
    Location
    UK
    MS-Off Ver
    Office 365
    Posts
    2,108

    Re: Pivot table field selection based on selection in other Pivot

    Upload a sample. To upload: Go Advanced - Manage Attachments -

  7. #7
    Registered User
    Join Date
    07-03-2019
    Location
    Stockholm, Sweden
    MS-Off Ver
    2013
    Posts
    61

    Re: Pivot table field selection based on selection in other Pivot

    Originally Posted by PaulM100
    Upload a sample. To upload: Go Advanced - Manage Attachments -
    OK, now I got home (our firewall doesn't let me upload at work…) so here's a sample file - very much simplified but same names for worksheet and pivots and same cell for previous year as my original.
    Thanks a lot already for your help!!
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    07-03-2019
    Location
    Stockholm, Sweden
    MS-Off Ver
    2013
    Posts
    61

    Re: Pivot table field selection based on selection in other Pivot

    Quote Originally Posted by PaulM100 View Post
    Upload a sample. To upload: Go Advanced - Manage Attachments -
    I SOLVED IT!! Based on your code and with a little support from google and other forum entries I managed to understand enough to change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    Then copy-pasted that section for the second pivot - and now it's working, wohoo! :-)

    Thanks a lot for a great push in the right direction!!

  9. #9
    Forum Expert PaulM100's Avatar
    Join Date
    10-09-2017
    Location
    UK
    MS-Off Ver
    Office 365
    Posts
    2,108

    Re: Pivot table field selection based on selection in other Pivot

    That's the best way to learn. If you need help again, please ask.

+ 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: 2
    Last Post: 12-10-2014, 12:42 AM
  2. Change Pivot Table Column field on Slicer selection (Excel 2013)
    By kevboyo in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 10-27-2014, 11:36 PM
  3. I must enable PIVOT TABLE default field selection formatting
    By miekoo in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 03-28-2013, 03:41 PM
  4. Update Page Field on selection of another page field in excel pivot table
    By ashwanileon in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-29-2011, 12:33 PM
  5. Disable Selection on Pivot Table field, multiple tables
    By Calieth in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-19-2010, 12:09 PM
  6. Pivot Table Field Selection via VB
    By SystemsAccountant in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-19-2009, 06:25 AM
  7. Selection of multiple values for pivot table field
    By Michael Glenn in forum Excel General
    Replies: 0
    Last Post: 02-23-2006, 10:15 AM

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