+ Reply to Thread
Results 1 to 5 of 5

Set date filter for 2 different pivots

  1. #1
    Registered User
    Join Date
    11-18-2015
    Location
    Netherlands
    MS-Off Ver
    2010
    Posts
    9

    Set date filter for 2 different pivots

    Hello,

    - In sheet 1 there is a pivot with a date filter.
    - In sheet 2 there is an other pivot with different data but with the same date filter

    In sheet 3 I want to set a date filter which selects the dates of both pivots.

    I believe this should be possible, only I have no idea how. Can somebody help me with this?


    Thanks in advance!

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,956

    Re: Set date filter for 2 different pivots

    I don't know what MS-Office Version 8 is. But in Excel 2010 and later there is something called a slicer. If your pivot tables are built from the same data source, then you can hook up the slicer to update them both at the same time.

    If the pivot tables are not built from the same data source, then some VB Coding is needed. Without a sample workbook, the best I can do is describe how this would go. First we have to ask a couple of questions. Are there dates in one data source that are not in the other? If so, is one data source all inclusive of all the dates? Or do I have to combine the data sources to get all the potential dates?

    If we have to combine the data sources to get all the potential dates, I would create two "helper" pivot tables to get a list of unique dates from both tables, combine them using VBA and then get a unique list of dates by pivoting the combined list.

    Then I'd use data validation against the combined unique list as the date on which to search. I then use COUNTIF to see how many times the date appears in each data source. If the COUNTIF is greater than zero, I set the filter on that table. If not, meaning that the table does not contain the date, I issue a warning and do not attempt to set the filter.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Registered User
    Join Date
    11-18-2015
    Location
    Netherlands
    MS-Off Ver
    2010
    Posts
    9

    Re: Set date filter for 2 different pivots

    Hello,


    Thanks for your help. (I am using excel 2010)

    It are 2 different pivot tables with 2 different Data Sources, but both sources have exactly the same dates in it. So in this case VBA is needed but I don't know much about this.

    Example:
    - In sheet 1 I have call data and in sheet 2 the pivot for this data.
    - In Sheet 3 I have sales data and in sheet 4 the pivot for this data.
    - In sheet 5 I want to be able to select the dates for both pivots. NOTE: I don't want a pivot table in sheet 5, I just want to be able to select the dates for both pivots.

    I hope you can help me. Thanks in advance!

  4. #4
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,956

    Re: Set date filter for 2 different pivots

    Without a sample spreadsheet, the best I can do is explain what needs to be done. Since you have the same dates, the issue is greatly simplified.

    On one (or both) of the spreadsheets, use a change event on the page code to detect when you change the filter. Set the filter on the other table to the target value. This code should work assuming the cell B1 is where the filter is. This should be placed in the worksheet module. "Target" is just a fancy name for "selected cell." In this setup you don't need another dropdown list. Change the date on one spreadsheet, it will change on the other.

    Please Login or Register  to view this content.

  5. #5
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,956

    Re: Set date filter for 2 different pivots

    On second reading (a day later), I'm going to modify my code. If you have the pivot table filters pointing at each other then you may wind up in an infinite loop. If you change the filter on Sheet A, it changes the filter on Sheet B, but since it changed it will change the filter on Sheet A which will change the filter on Sheet B ...

    To prevent this runaway condition, we need to turn off event tracking and then turn it back on.

    Please Login or Register  to view this content.

+ 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. [SOLVED] Update all pivots with column filter
    By jeroenft in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-17-2015, 03:34 PM
  2. One filter for multiple Pivots
    By mstoto in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 08-18-2014, 05:57 AM
  3. [SOLVED] Pivots Table filter
    By so_nice3 in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 08-13-2014, 02:05 AM
  4. Replies: 0
    Last Post: 10-18-2013, 11:35 AM
  5. Comparing several pivots to filter information
    By Rbeusink in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 09-30-2013, 07:32 AM
  6. VBA to change filter for n pivots based on page filter selection for the first pivot
    By shama.arige in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-19-2011, 11:42 AM
  7. Multiple Pivots, One Filter, etc.
    By stmartinez in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 11-05-2009, 06:08 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