+ Reply to Thread
Results 1 to 18 of 18

Limiting/Hiding PivotItems

  1. #1
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Limiting/Hiding PivotItems

    In my macro I use a basic routine twice to only show a small selection from a vast array of pivot items (Pi and PT are previously defined):
    Please Login or Register  to view this content.
    The oveall macro works just fine, but Extremely Slowly. I have Manual Updating turned to True, and Screen Updating turned off. Walking through the code, it's these two PivotItems sections that are slowing everything down. Is there a faster way to do this?

    Any help is highly appreciated.

  2. #2
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Limiting/Hiding PivotItems

    Can you post a sample wb?

  3. #3
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: Limiting/Hiding PivotItems

    Not really. The pivot I'm manipulating is in a workbook from our IT group. It's based on a huge datasource, to which I have no acess other than through the pivot. I can doubleclick and pull up some of the data, but it's a truly large set, and includes Names and Pay information. If I were to limit the data I'm sure things would go easier and faster. But I CAN show you how many fields are in the two PivotItem categories; see attached.
    Attached Files Attached Files

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

    Re: Limiting/Hiding PivotItems

    using pivotfilters should be a lot faster than looping through all the pivotitems
    Josie

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

  5. #5
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Limiting/Hiding PivotItems

    Maybe something like this

    Please Login or Register  to view this content.

  6. #6
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: Limiting/Hiding PivotItems

    Jiejenn,
    I tried it your way, no difference in time.

    JosephP,
    Okay, I'll bite; how do we use "pivotfilters" in this case, via VBA?

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

    Re: Limiting/Hiding PivotItems

    my bad-not enough coffee. the approach I was thinking of is for autofilters and I don't suppose your data source is olap?
    how many items are you looping through? I'm on a cell so can't see your workbook.
    you may be able to speed it up by testing if each item is visible and then only hide it if it is and it's not a department you want.

  8. #8
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: Limiting/Hiding PivotItems

    For departments, there are only 46, of which I want 6.
    Of Posn Func, there are 745, of which I want 4.

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

    Re: Limiting/Hiding PivotItems

    can you alter the query that pulls from the data source? what is the data source-a db or cube?

  10. #10
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: Limiting/Hiding PivotItems

    Nope, the workbook, including query and datasource, is locked down tight. Literally all I have access to is the pivot table itself. I COULD double-click the Grand Total, and from the page that's generated create a new pivot table, but seems like that would take even longer.

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

    Re: Limiting/Hiding PivotItems

    ok. have you tried
    -turning off subtotals
    -setting the field sort to manual
    -testing visibility before setting it
    -turning off calculation and events

  12. #12
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: Limiting/Hiding PivotItems

    I guess I should have posted the whole macro to begin with. I've also attached a picture of how the PT looks when I come into it. There are 92 "Par_Program" lines. Each Department has about 70 of those. Each Par_Program has up to 745 Posn-Funcs. So you can see there's a mass of data available. My job in this macro is to whittle it down to two specific views.
    Please Login or Register  to view this content.
    Attached Images Attached Images

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

    Re: Limiting/Hiding PivotItems

    this is about all I can think of to try if you can't alter the data source
    Please Login or Register  to view this content.

  14. #14
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: Limiting/Hiding PivotItems

    JosephP,

    Thanks so much. I like the way you rearranged it all; that shows me a few tricks I hadn't thought of. I hope you don't mind if I ask some questions:

    1) What's the purpose of these two lines of code, how do they help?
    Please Login or Register  to view this content.
    2) I see where you turn Calculation to Manual, but don't see where you turn it back to auto. And what is the meaning of these two lines?
    Please Login or Register  to view this content.
    Thanks,
    John

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

    Re: Limiting/Hiding PivotItems

    1. turning off sorting on a pivot field is an old trick used when hiding/showing items. I'm not sure if it makes any difference in newer versions of excel but it used to be invaluable in preventing errors.
    2. the first line stores the current calculation setting (since it might not be automatic) and then that setting is restored by the second line. it's better practise than simply resetting to automatic calculation

  16. #16
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: Limiting/Hiding PivotItems

    Followup-The selection for the Posn Func codes isn't happening. I'm walking through the code to find out why.
    Update-had to change this
    Please Login or Register  to view this content.
    to this
    Please Login or Register  to view this content.


    ---------- Post added at 07:41 AM ---------- Previous post was at 07:33 AM ----------

    JosephP,

    I crossed over your last post, so just read it. Thanks for explaining, especially the 1Calc piece. I've always just returned calculation to automatic; nice to know there's a way to restore it to whatever it was when I came in.

    Thanks for all your help on this. I don't know that we achieved much of a speed difference, but the code is a lot tighter and more efficient now, so I'm pretty happy. Thanks for helping and teaching.
    Last edited by jomili; 08-30-2012 at 08:37 AM.

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

    Re: Limiting/Hiding PivotItems

    my pleasure. I still have this idea in my head that pivotfilters ought to accept an array of values-as the pivot field dropdown effectively does-without having to loop (in olap pivots you can create a visibleitemslist). maybe in office 16 ;-)

  18. #18
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: Limiting/Hiding PivotItems

    I'm not going to hold my breath, and I suggest you don't either.

+ 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