+ Reply to Thread
Results 1 to 9 of 9

Finding Second Occurrence if Index Match Returns -

Hybrid View

zmster2033 Finding Second Occurrence if... 03-22-2016, 12:21 PM
Tony Valko Re: Finding Second Occurrence... 03-22-2016, 12:37 PM
JohnTopley Re: Finding Second Occurrence... 03-22-2016, 12:46 PM
zmster2033 Re: Finding Second Occurrence... 03-22-2016, 01:12 PM
Tony Valko Re: Finding Second Occurrence... 03-22-2016, 01:24 PM
JohnTopley Re: Finding Second Occurrence... 03-22-2016, 01:18 PM
zmster2033 Re: Finding Second Occurrence... 03-22-2016, 02:08 PM
Tony Valko Re: Finding Second Occurrence... 03-22-2016, 02:50 PM
JohnTopley Re: Finding Second Occurrence... 03-22-2016, 02:23 PM
  1. #1
    Registered User
    Join Date
    08-20-2014
    Location
    CLT
    MS-Off Ver
    2010
    Posts
    61

    Finding Second Occurrence if Index Match Returns -

    Good afternoon,

    I am in need of a formula that searches a table for a second occurrence of criteria if the first occurrence returns a -.

    Example

    Item State Qty
    A NC -
    A NC 10
    B SC -

    In this instance, I would want to return qty 10 for Item A State NC. However, if item and state only existed once (i.e. Item B State SC) and had a - in the Quantity field return a -.

    Thanks.

  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: Finding Second Occurrence if Index Match Returns -

    Maybe this...

    Data Range
    A
    B
    C
    D
    E
    F
    G
    1
    Item
    State
    Qty
    Item
    State
    Qty
    2
    A
    NC
    -
    A
    NC
    10
    3
    A
    NC
    10
    4
    B
    SC
    -
    5
    ------
    ------
    ------
    ------
    ------
    ------
    ------


    This array formula** entered in G2:

    =MAX(IF((A2:A4=E2)*(B2:B4=F2),C2:C4))

    ** 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.

  3. #3
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,954

    Re: Finding Second Occurrence if Index Match Returns -

    Beaten to it!

  4. #4
    Registered User
    Join Date
    08-20-2014
    Location
    CLT
    MS-Off Ver
    2010
    Posts
    61

    Re: Finding Second Occurrence if Index Match Returns -

    All,

    Thanks for the response. This resolves my issue when there are 2 or more occurrences; however, for the formula provided for Item B State SC this returns a 0 instead of a "-". Anyway to return an "-" instead of 0 if that is what is listed? There will be instances where there may be a 0 in my actual data which has a different value than the "-".

    Thanks.

  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: Finding Second Occurrence if Index Match Returns -

    The dash - is a common accounting format for numeric 0. The cell contains 0 but is formatted to display as -.

    Are you saying that the dashes are not formatted zeros?

    You could have both zeros and dashes for an item?

    If that's the case then what result do you expect if an item has both 0 and a dash?

    Can you post several more examples and show us what results you expect?

  6. #6
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,954

    Re: Finding Second Occurrence if Index Match Returns -

    Try

    =IFERROR(INDEX($C$1:$C$50,SMALL(IF((A1:A50="B")*($B$1:$B$50="SC")*(ISNUMBER($C$1:$C$50)),ROW($A$1:$A$50)-ROW($A$1)+1),1)),"-")

    Enter with Ctrl+Shift+Enter

    Put Item/state in cells as per Tony's formula

  7. #7
    Registered User
    Join Date
    08-20-2014
    Location
    CLT
    MS-Off Ver
    2010
    Posts
    61

    Re: Finding Second Occurrence if Index Match Returns -

    Tony,

    Correct, the dashes are not formatted 0's. In this case "-" indicates no service. If there is a number (0 included) that should be returned over the hyphen. I have attached an example of what I am looking for. Hope this helps.
    Attached Files Attached Files

  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: Finding Second Occurrence if Index Match Returns -

    Try this array formula** entered in E2 and copied down:

    =IF(SUMIFS(Data!F$2:F$6,Data!A$2:A$6,A2,Data!B$2:B$6,B2,Data!D$2:D$6,C2),MAX(IF((Data!A$2:A$6=A2)*(Data!B$2:B$6=B2)*(Data!D$2:D$6=C2),Data!F$2:F$6)),IF(COUNTIFS(Data!A$2:A$6,A2,Data!B$2:B$6,B2,Data!D$2:D$6,C2,Data!F$2:F$6,"-"),"-",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.

  9. #9
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,954

    Re: Finding Second Occurrence if Index Match Returns -

    Try

    =IFERROR(INDEX(Data!$F$1:$F$50,SMALL(IF((Data!$A$1:$A$50=A2)*(Data!$B$1:$B$50=B2)*(ISNUMBER(Data!$F$1:$F$50)),ROW($A$1:$A$50)-ROW($A$1)+1),1)),"-")

    Enter with Ctrl+Shift+Enter

    Match on City & Country (??)

+ 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. Index match nth occurrence or just get nth match
    By sdl2 in forum Excel General
    Replies: 10
    Last Post: 05-21-2018, 09:59 AM
  2. [SOLVED] Index match that returns 0
    By Keldion in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 03-11-2016, 03: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. Using index and match to return a value based on earliest occurrence (MONTH)
    By potatoman in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 09-09-2014, 06:12 AM
  5. Using index and match to return a value based on earliest occurrence (MONTH)
    By potatoman in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-06-2014, 06:16 AM
  6. [SOLVED] Index Match row value and nth occurrence of header
    By dm@stams in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-22-2013, 05:43 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

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