+ Reply to Thread
Results 1 to 8 of 8

Error using Array: Index, Small, Row to pull list from PivotTable

  1. #1
    Registered User
    Join Date
    02-21-2014
    Location
    San Francisco, CA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Error using Array: Index, Small, Row to pull list from PivotTable

    Hi All,

    I am currently trying to write a formula to pull back a column of row labels in a pivot table (on another worksheet) based off of the text in a drop-down data validation.

    For example, say I have a pivot where the row label in column A is "Species" and there are two types of species, Cat and Dog. Column B of row labels in the pivot is "Breed" and would say Golden Retriever, Labrador, Siamese, etc.

    Basically, on the other worksheet if I have the data validation drop-down options as either Cat or Dog, I want to be able to select Dog and then have the formula pull back every Species of Dog from the pivot table in list format.

    I am currently using the formula below. The issue somehow lies in pulling from the Pivot Table. When I copy and paste values of a sample of data from the pivot it works perfectly but when I try to reference the same exact data sample within the pivot the formula doesn't work. I've tried messing around with indirect but can't get that to work either. Any ideas?


    {=IF(ISERROR(INDEX($E$1:$G$13,SMALL(IF($E$1:$E$13=$C$1,ROW($E$1:$E$13)),ROW(1:1)),3)),"",INDEX($E$1:$G$13,SMALL(IF($E$1:$E$13=$C$1,ROW($E$1:$E$13)),ROW(1:1)),3))}

    Thanks in advance for the help!

  2. #2
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Error using Array: Index, Small, Row to pull list from PivotTable

    What type of data is the formula supposed to be returning? Text? Numbers? Could be both? Something else?

    You can make the formula shorter and more efficient depending on what version of Excel you're using.

    Hard to tell why it's not working correctly. What results are you getting? Just blanks?
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  3. #3
    Registered User
    Join Date
    02-21-2014
    Location
    San Francisco, CA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Error using Array: Index, Small, Row to pull list from PivotTable

    Thanks for the reply, Tony.

    I'm trying to pull back text (row labels) from a pivot table but it could potentially be text or numbers. I'm using excel 2010. The formula is returning blanks which is a result of the iserror "". Seems like there is some sort of change I need to make to the formula so that it can pull from a pivot.

    Really appreciate the help.

  4. #4
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Error using Array: Index, Small, Row to pull list from PivotTable

    I never use pivot tables but you should be able to use your formula to pull data from one.

    Can you post a SMALL sample file so we can see what's happening?

    SMALL = about 20 rows worth of data

  5. #5
    Registered User
    Join Date
    02-21-2014
    Location
    San Francisco, CA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Error using Array: Index, Small, Row to pull list from PivotTable

    CatDog.xlsm

    Hopefully the attachment works. Let me know if there are issues.

    So basically I've got the formula I want working in columns R and S with sample data. When you toggle the drop down between cat and dog it updates the list.

    The cells I highlighted yellow (Column T & U) have the same formulas referencing the data in the pivot table which ultimately should pull back the same lists, but I can't get the formula to work with the pivot.

    Thanks.

  6. #6
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Error using Array: Index, Small, Row to pull list from PivotTable

    Hi,

    You need to be careful with your ROW constructions. Your formula in T2 should be either:

    =IF(ISERROR(INDEX($A$23:$D$40,SMALL(IF($A$23:$A$40=$R$1,ROW($A$23:$A$40)-MIN(ROW($A$23:$A$40))+1),ROWS($1:1)),2)),"",INDEX($A$23:$D$40,SMALL(IF($A$23:$A$40=$R$1,ROW($A$23:$A$40)-MIN(ROW($A$23:$A$40))+1),ROWS($1:1)),2))

    or:

    =IF(ISERROR(INDEX($A$23:$D$40,SMALL(IF($A$23:$A$40=$R$1,ROW($A$23:$A$40)-ROW($A$23)+1),ROWS($1:1)),2)),"",INDEX($A$23:$D$40,SMALL(IF($A$23:$A$40=$R$1,ROW($A$23:$A$40)-ROW($A$23)+1),ROWS($1:1)),2))

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  7. #7
    Registered User
    Join Date
    02-21-2014
    Location
    San Francisco, CA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Error using Array: Index, Small, Row to pull list from PivotTable

    Ah, awesome it worked!

    When you get a chance would you mind giving a brief explanation of the logic behind that? Just want to make sure I understand what's going on backing out the min+1.

    Thanks again to XOR and Tony for the help!

  8. #8
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Error using Array: Index, Small, Row to pull list from PivotTable

    Since the OP is using Excel 2010 we can shorten those considerably.

    =IFERROR(INDEX($A$23:$D$40,SMALL(IF($A$23:$A$40=$R$1,ROW($A$23:$A$40)-MIN(ROW($A$23:$A$40))+1),ROWS($1:1)),2),"")

    =IFERROR(INDEX($A$23:$D$40,SMALL(IF($A$23:$A$40=$R$1,ROW($A$23:$A$40)-ROW($A$23)+1),ROWS($1:1)),2),"")

    Both still array entered.

+ 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] INDEX MATCH and MIN/SMALL to pull first and second smallest values from array
    By tlafferty in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-18-2014, 04:03 AM
  2. [SOLVED] INDEX SMALL array formula issue
    By davepoth in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-27-2013, 07:13 AM
  3. [SOLVED] Slow index/small/row array
    By Jovica in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 12-06-2012, 06:59 AM
  4. Adding another condition to an INDEX SMALL array
    By reborn537 in forum Excel General
    Replies: 3
    Last Post: 12-21-2011, 09:27 AM
  5. INDEX SMALL ROW array function
    By ACurtis802 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 12-10-2009, 02:10 AM

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