+ Reply to Thread
Results 1 to 7 of 7

Index Match (row and header) that returns the first non-zero value

  1. #1
    Registered User
    Join Date
    03-02-2016
    Location
    NC, USA
    MS-Off Ver
    2013
    Posts
    6

    Index Match (row and header) that returns the first non-zero value

    The attached table image illustrates the type of data I am working with.

    When I use the following formula (where A16 is SiteA and B16 is Queso), it returns 0 because that is the first value the function finds based on the criteria:

    =INDEX(Table1[[Burritos]:[Tacos]],MATCH(A16,Table1[Site],0),MATCH(B16,Table1[[#Headers],[Burritos]:[Tacos]],0))

    How can I find the first non-zero value that matches the criteria? The value I am looking for is 5.

    Sample worksheet attached.
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by jmanp; 07-05-2016 at 03:38 PM.

  2. #2
    Forum Expert
    Join Date
    10-09-2012
    Location
    Dallas, Texas
    MS-Off Ver
    MO 2010 & 2013
    Posts
    3,049

    Re: Index Match (row and header) that returns the first non-zero value

    Without a sample workbook.
    Please Login or Register  to view this content.

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    Last edited by mikeTRON; 07-05-2016 at 12:41 PM.
    Please ensure you mark your thread as Solved once it is. Click here to see how.
    If a post helps, please don't forget to add to our reputation by clicking the star icon in the bottom left-hand corner of a post.

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

    Re: Index Match (row and header) that returns the first non-zero value

    Try this...

    Data Range
    A
    B
    C
    D
    1
    Site
    Burritos
    Salsa
    Queso
    2
    SiteA
    2
    3
    3
    SiteB
    1
    4
    SiteA
    5
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    SiteA
    Queso
    5


    This array formula** entered in C16:

    =INDEX(D2:D4,MATCH(1,(A2:A4=A16)*(INDEX(B2:D4,0,MATCH(B16,B1:D1,0))<>""),0))

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  4. #4
    Registered User
    Join Date
    03-02-2016
    Location
    NC, USA
    MS-Off Ver
    2013
    Posts
    6

    Re: Index Match (row and header) that returns the first non-zero value

    @Tony Valko

    In the outermost argument you told it to look in, or "INDEX", cells D2:D4. I need it to know which column to look in based on cell B16.

    Your tips are still helpful and gave me some more ideas but still can't quite get it to work. Racking my brain....

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

    Re: Index Match (row and header) that returns the first non-zero value

    Quote Originally Posted by jmanp View Post
    @Tony Valko

    In the outermost argument you told it to look in, or "INDEX", cells D2:D4. I need it to know which column to look in based on cell B16.
    That's what the highlighted portion is doing:

    =INDEX(D2:D4,MATCH(1,(A2:A4=A16)*(INDEX(B2:D4,0,MATCH(B16,B1:D1,0))<>""),0))

  6. #6
    Registered User
    Join Date
    03-02-2016
    Location
    NC, USA
    MS-Off Ver
    2013
    Posts
    6

    Re: Index Match (row and header) that returns the first non-zero value

    @Tony

    Thanks, this pointed me in the right direction and I've got it figured out. Check out the new sample worksheet attached. I've reworked it to make it a little bit clearer.

    Here is the formula I am using:

    Please Login or Register  to view this content.
    The formula in J2 (the one you have provided) works well because it is hard-coded to INDEX column D in the table. I could copy that down to subsequent rows as long as I am only interested in Queso. However, in the next row, I am looking to return the amount of Salsa, as indicated in H3. I opened up the first array to the whole table and then used a match function in the column look-up portion of the index function to use H3 to determine the correct column and the correct value.
    Attached Files Attached Files

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

    Re: Index Match (row and header) that returns the first non-zero value

    Good deal. Thanks for the feedback!

+ 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 that returns 0
    By Keldion in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 03-11-2016, 03:41 PM
  2. Index Match that returns all non zero values in row
    By kvarner in forum Excel Formulas & Functions
    Replies: 44
    Last Post: 03-03-2016, 06:41 PM
  3. [SOLVED] Index+Match+Match doesnt returns right values
    By SwissExcel in forum Excel General
    Replies: 10
    Last Post: 07-21-2015, 08:39 AM
  4. Sum of multiple Index Match returns!?
    By Spicey_888 in forum Excel General
    Replies: 6
    Last Post: 04-25-2015, 05:30 AM
  5. [SOLVED] Index/Match returns #N/A result
    By pjkcpa in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-27-2014, 02:23 PM
  6. [SOLVED] MATCH/INDEX Formula Returns an Error Instead of 0
    By livifivil in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-07-2013, 04:18 PM
  7. Excel 2007 : Index Match returns 0
    By Martin Chamberlin in forum Excel General
    Replies: 6
    Last Post: 10-27-2011, 09:49 PM

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