+ Reply to Thread
Results 1 to 30 of 30

Controlling Multiple Pivots

  1. #1
    Registered User
    Join Date
    08-14-2009
    Location
    NY, NY
    MS-Off Ver
    Excel 2007
    Posts
    17

    Controlling Multiple Pivots

    Hello Everyone
    Would be great if someone can help me with this problem.

    I am working on an excel sheet (2007) with about 8 pivots from the same data (huge db). The 8 pivots take a different cuts of data. One filter element is same across all pivots. (For instance let us say that filter is City names: with 10 different city values in it- NY, London, Chicago etc)

    What I would like to do is have a system where I just chose NY in one place and all the 8 pivots should use NY as one of the filters and refreash the data accordingly.

    What I am doing now is I got to each pivot, choose NY first and then refreash all for the data.

    Pls help and make my life easier!!
    :-)
    Thanks
    Bala

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Controlling Multiple Pivots

    I think we'd need more info - is the field a Report Filter field, Row Label / Column Label etc... if Report Filter do you have multi selection enabled for ex. ?
    (ie in earlier version of XL the Page Field aka Report Filter was a single select - still the default in 2007 but can be adjusted)

    Where are the PT's located ?

    Are there any other PTs in the Workbook that are not related ?

    If all stored on one sheet the same question but for that one sheet only...

    What you want to do can be done but the more info we have the better...

  3. #3
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561

    Re: Controlling Multiple Pivots

    May I suggest this is very not 'New User', and of all places, would be best answered in Excel Programming - this is for your best chance of getting help (not that DO isn't great, but not many people visit this little area).

    CC

  4. #4
    Registered User
    Join Date
    08-14-2009
    Location
    NY, NY
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: Controlling Multiple Pivots

    Thanks Charlie. I will post the same question in the excel programming thread
    Cheers
    Bala

  5. #5
    Registered User
    Join Date
    08-14-2009
    Location
    NY, NY
    MS-Off Ver
    Excel 2007
    Posts
    17

    Smile Re: Controlling Multiple Pivots

    Thanks DO. These are great questions. My bad I didnt give more info at the beginning.

    I hope the following answers your questions..

    1. The selection will be one of the Report Filter Elements
    2. Multiple items can be selected but I want only one at a time. So no multiple items selection required
    3. ALL PTs are located in the same work book. I have kept the raw data in one tab and all he PT in one tab.
    4. At the end of the day if this works out my vision is have a macro in the first dashboard tab where an user selects a city and press update, the macro takes the selected city value and updates all 8 Pivots with that city name, refreash it and bang.. the output page has the required outputs for the city..

    Thanks again
    Cheers

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Controlling Multiple Pivots

    Here's a quick sample file with three pivots on one sheet where changing the specified field on any one of three pivots updates the other two accordingly. The code resides in the Sheet Object (ie in VBE see Pivot sheet object), though by no means the finished article it should help I hope.

    The file uploaded is in 2007 format given the slight differences in PT functionality between 2007 and earlier versions.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    08-14-2009
    Location
    NY, NY
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: Controlling Multiple Pivots

    Thanks a lot buddy! I think this would work

    This forum rocks
    Cheers

  8. #8
    Registered User
    Join Date
    08-14-2009
    Location
    NY, NY
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: Controlling Multiple Pivots

    Dear DO
    I tried this and it does work like a charm. So simple yet so powerful an answer!

    YOU ARE GOD!!
    Thanks again
    Cheers

  9. #9
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561

    Re: Controlling Multiple Pivots

    I'd like to recognise formally the inauguration of the church of DO
    :D

  10. #10
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Controlling Multiple Pivots

    I told them it wasn't a God complex...

  11. #11
    Registered User
    Join Date
    08-14-2009
    Location
    NY, NY
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: Controlling Multiple Pivots

    Hey DO
    Have a qq for you. I wanted to get more expertise and experience in VB coding for excel. Just so I can write simple codes like what you helped out with me on the pivots.

    Any thoughts/words of wisdom on how to get started on this through this forum.. Would it make sense to generally go through the archives and learn in small incremental steps?

    Thanks for your thoughts if any
    :-)

  12. #12
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Controlling Multiple Pivots

    Wisdom ? No not really... what I know I've sourced almost entirely from Forums like this and of course the Macro Recorder... I've never owned a book and my code at times highlights this fact unfortunately.

    Best way to get into VBA is to think of something you do presently that takes far longer than you would like and try to work out how you could automate it... work from there ...

    IMO no-one should ever be too proud to use the macro recorder as it's an excellent tool to quickly determine the core syntax, like most user-friendly utilities the Macro Recorder invariably generates superfluous code but what it does show you are the vital bits upon which you can base your "streamlined" code.

    I've been coding best part of ten years and what I don't know far outweighs that which I do...

  13. #13
    Registered User
    Join Date
    08-14-2009
    Location
    NY, NY
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: Controlling Multiple Pivots

    Hey DO
    Another follow up doubt on controlling multiple pivots with one single entry. You had suggested the following code ( and I had mentioned that we will only have single entry in the record filter)

    You had suggested the following code and it worked very well.... Now i just realized there is actually a need for multiple selection in the record filter. How should I change this code to reflect that.. (i.e I choose multiple entry in a record filter of one pivot and all pivots will get updated with the same multiple entry selections)

    Thanks much
    :-)

    Please Login or Register  to view this content.
    Last edited by DonkeyOte; 08-28-2009 at 01:05 PM.

  14. #14
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Controlling Multiple Pivots

    sailor64, please note:

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

    please edit your post per the above

  15. #15
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Controlling Multiple Pivots

    I am breaking my own rule here as I am going to be going offline soon and may not be able to post back but based on the original sample file you could perhaps try:

    Please Login or Register  to view this content.
    May be better methods.

    I have added tags to your last post on this occasion though please ensure you adhere to rules going forward. Apologies to all for "bending the rules" here.

  16. #16
    Registered User
    Join Date
    08-14-2009
    Location
    NY, NY
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: Controlling Multiple Pivots

    Thank you so much DO for your help and also for updating the code format. I didnt know how to do it. I tried couple of things and I thought it will automatically post into the code format if I reply. Apologies for the same

    Will defnly follow this procedure going fwd.
    Cheers

  17. #17
    Registered User
    Join Date
    08-14-2009
    Location
    NY, NY
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: Controlling Multiple Pivots

    Hey DO
    I tried incorporating your suggested code. But for some strange reason it works well (selecting multiple items in the record filters across pivots) with your sample file but if I copy the same in my source file selecting multiple items does not work. Would you have an idea what may be causing this?

    This is the code that I used

    Please Login or Register  to view this content.

  18. #18
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Controlling Multiple Pivots

    In reality I think I would need to see the file in question... I am presuming of course it is XL2007 format (I don't believe you can't select multiple page items other than in OLAP PT's in earlier versions)

    If you can't post the file here directly given confidentiality issues you can PM me and I will give you an address to which you can mail it - for me eyes only etc - confidentiality assured...

  19. #19
    Registered User
    Join Date
    08-14-2009
    Location
    NY, NY
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: Controlling Multiple Pivots

    Hey DO
    THe attached is the morphed version of the file that I am working on.

    What I did essentially, is took a copy of the main pivot and raw data tab and removed bunch of rows in the raw data tab and changed the names etc for data confidentiality and reducing the size of the file.

    Interestingly once I am did this and tried multiple selection on the record filter field it works!! but in my main file with the same code below (more pivots and data it goes into an endless loop of calcution. Never stops.. the status goes.. calculation 2 process (0%) then it goes to 90% and then again comes back to 0%.. ). Just cant understand what is happening here

    This is the code that I have that is in the attached file and my main file

    Please Login or Register  to view this content.
    Any help in solving this mystery is much appreciated
    Cheers
    Attached Files Attached Files

  20. #20
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Controlling Multiple Pivots

    To be honest I didn't experience any real issues but I would alter the code such that instead of repeating all of the code for each Field you iterate the Fields running the same code...

    Please Login or Register  to view this content.
    ...in the above you can see that rather than repeating the big block of code for the 2nd field I have put the fields of interest into an Array (vFields) and subsequently iterated that Array repeating the code.

    And to clarify, the above worked for me without issue on your file.

  21. #21
    Registered User
    Join Date
    08-14-2009
    Location
    NY, NY
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: Controlling Multiple Pivots

    Thanks DO again. I tried this code and I really do not know what is happening but once I put this code in and choose multi select and select couple of elements in one pivot, the excel goes on a an endless loop of calculations. I really am not sure what is happening. If I just choose one everything is fine (same code that you suggested last).

    I have a pivot on another tab. Will this cause the above issue by any chance? THe only diff btwn what I sent and what I have is the size of the data (much larger), the number of pivots in the tab (the one I gave you had 3, my original file has about 8 pivots in that tab) and one more tab with pivots that I have assumed will not be affected by this code

    Cheers

  22. #22
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Controlling Multiple Pivots

    I'm going to need to see the file in full... I can't think why you're going into a loop given the disabling of events etc ... what happens if you run the code I provided on the file you provided (rather than your real file), it worked for me without incident - can you confirm likewise ? This will help narrow down possible issues.

  23. #23
    Registered User
    Join Date
    08-14-2009
    Location
    NY, NY
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: Controlling Multiple Pivots

    Yes. Your code when used in the test file you provided works perfectly. No issues at all.

    When I copy the exact code to my main worksheet (the filter element names are the same), and I choose multi elements in the pivot, it goes on an endless loop!!

    As I said the only diff between the test file and my original file: Data is large, number of pivots per sheet are around 6 instead of 2 in the test file and there are other tabs as well of which one has a pivot.

    Lastly, i also noticed that in the excel icon for the file has an yellow exclamation mark to it... Wonder why? does this ring any bell to you...

    Thanks for all your help
    Cheers

  24. #24
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Controlling Multiple Pivots

    I will pm you - I need to see the file with my own eyes.

    Re: ! ... .xlsm files have ! in the icon

  25. #25
    Registered User
    Join Date
    10-04-2009
    Location
    Bosotn
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Controlling Multiple Pivots

    Hi DonkeyOte,

    Would it be possible to modify the above code (which by the way works awesome with myltiple selections) to loop through multiple worksheets...such that I can pick on filter on the main page and the code will loop through each pivot table in each worksheet to make the changes?

    Thank you!

  26. #26
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561

    Re: Controlling Multiple Pivots

    In DO's absence...

    Yes, but please start a new thread, (cross-referencing this one) asking exactly that question.
    The reason we do this is it makes it easier for others searching the forum to find an answer to their questions - on that basis, please title your thread carefully to describe your need.
    CC


    If you feel really indebted please consider a donation to charity. My preferred charity is ActionAid but there are plenty of worthy alternatives.

  27. #27
    Registered User
    Join Date
    03-23-2011
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2007
    Posts
    1

    Re: Controlling Multiple Pivots

    Hi DO,
    This code worked perfectly for what I was trying to accomplish on a report. However, I'm trying to find out what should I do to control two pivot tables with different source data from the same filter on the same sheet. In Excel 2010, I was able to accomplished this with the slicers, but when I loaded the file at work (Excel 2007) the slicers went away because of the compatibility issue. I would send the file, but I this point it's rather huge due to all the data in it.
    So, let me specify a bit more, the pivot tables are in spreadsheet "OVERALL SUMMARY" and the data is located in two different sheets "DATADUMP" & "DATADUMP2"
    The data used in the filter is the same (month number), but it comes from two different tables uploaded from a database. I'm just trying to make it easier for the user to change the month on any particular pivot table and reflect the data that belongs to that month on all the tables.
    I hope that you get this message since it has been quite some time since last post on this thread.

    Thanks,

    Otto

    ==============================
    Never mind... today 7/28 I opened the report and it seems to work the way I wanted with the previous code.
    Last edited by osotek; 07-28-2011 at 12:08 PM.

  28. #28
    Forum Contributor
    Join Date
    11-11-2012
    Location
    Muscat, Oman
    MS-Off Ver
    Office 365
    Posts
    521

    Re: Controlling Multiple Pivots

    Hi, Since this post is not marked as solved can i post here? Looking for some help from the Forum Moderator on the solution already provided here. Please advise if its ok to do so.
    Best Regards/VKS

  29. #29
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Controlling Multiple Pivots

    VKS,

    What do you want to post here? A solution or a question of your own?
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  30. #30
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Controlling Multiple Pivots

    VKS,

    What do you want to post here? A solution or a question of your own?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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