+ Reply to Thread
Results 1 to 8 of 8

Order Issue? Index Table Chooses The First Option When Two Rows Have Same Result

  1. #1
    Registered User
    Join Date
    11-11-2015
    Location
    Chicago, Illinois
    MS-Off Ver
    2007
    Posts
    29

    Order Issue? Index Table Chooses The First Option When Two Rows Have Same Result

    I asked a question about LARGE() and pulling data from a table. It was answered here:
    http://www.excelforum.com/excel-form...said-list.html

    The formula works great. There's something I noticed while replicating, though. If I generate a list where multiple results are the same, the names get mixed.

    For instance, in the following table:
    Make Model Top Speed
    Chrysler Coupe 120
    Dodge Pick-up 130
    Ford Sedan 123
    Chevy 4-door 150
    Pontiac 4-door 142
    Dodge Sedan 130
    Ford Electric 133
    Chevy Convertible 153
    Pontiac 4x4 142
    BMW Sedan 160
    Audi Supercar 226
    BMW Supercar 160

    ... and using the formula provided:
    =INDEX(B$3:B$14,MATCH(LARGE(IF(($D$3:$D$14="4-door")+($D$3:$D$14="Sedan")+($D$3:$D$14="Electric"),$F$3:$F$14),ROWS($2:2)),$F$3:$F$14,0))

    ... the resulting table includes a Dodge pick-up truck:
    BMW Sedan 160
    Chevy 4-door 150
    Pontiac 4-door 142
    Ford Electric 133
    Dodge Pick-up 130

    The issue is that the formula recognizes the Dodge sedan doing 130 mph. However, the Dodge pick-up has the same speed. The formula errantly prints the pick-up rather than sedan.

    Is there an ORDER modifier I need in this?

  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: Order Issue? Index Table Chooses The First Option When Two Rows Have Same Result

    Try this...

    Data Range
    A
    B
    C
    D
    E
    F
    G
    H
    1
    2
    Chrysler
    Coupe
    120
    4-door
    BMW
    Sedan
    160
    3
    Dodge
    Pick-up
    130
    Sedan
    Chevy
    4-door
    150
    4
    Ford
    Sedan
    123
    Electric
    Pontiac
    4-door
    142
    5
    Chevy
    4-door
    150
    Ford
    Electric
    133
    6
    Pontiac
    4-door
    142
    Dodge
    Sedan
    130
    7
    Dodge
    Sedan
    130
    Ford
    Sedan
    123
    8
    Ford
    Electric
    133
    9
    Chevy
    Convertible
    153
    10
    Pontiac
    4x4
    142
    11
    BMW
    Sedan
    160
    12
    Audi
    Supercar
    226
    13
    BMW
    Supercar
    160
    14
    ------
    ------
    ------
    ------
    ------
    ------
    ------
    ------


    All formulas are array formulas**.

    Enter this formula in H2:

    =IFERROR(LARGE(IF(ISNUMBER(MATCH(B$2:B$13,E$2:E$4,0)),C$2:C$13),ROWS(H$2:H2)),"")

    Enter this formula in G2:

    =IF(H2="","",INDEX(B:B,SMALL(IF(ISNUMBER(MATCH(B$2:B$13,E$2:E$4,0))*(C$2:C$13=H2),ROW(B$2:B$13)),COUNTIF(H$2:H2,H2))))

    Enter this formula in F2:

    =IF(H2="","",INDEX(A:A,SMALL(IF(ISNUMBER(MATCH(B$2:B$13,E$2:E$4,0))*(C$2:C$13=H2),ROW(B$2:B$13)),COUNTIF(H$2:H2,H2))))

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

    Select F2:H2 and copy down until you get a row full of blanks.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  3. #3
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Order Issue? Index Table Chooses The First Option When Two Rows Have Same Result

    Slightly different approach.

    In H2 array-enter this formula and fill down.
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Then in E2 array-enter this fill down and across to column G.
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Row\Col
    A
    B
    C
    D
    E
    F
    G
    H
    1
    Make Model Top Speed
    helper
    2
    Chrysler Coupe
    120
    BMW Sedan
    160
    160
    3
    Dodge 4-door
    130
    Chevy 4-door
    150
    150
    4
    Ford Sedan
    123
    Pontiac 4-door
    142
    142
    5
    Chevy 4-door
    150
    Ford Electric
    133
    133
    6
    Pontiac 4-door
    142
    Dodge Sedan
    130
    130
    7
    Dodge Sedan
    130
    Dodge 4-door
    130
    130
    8
    Ford Electric
    133
    Ford Sedan
    123
    123
    9
    Chevy Convertible
    153
    10
    Pontiac 4x4
    142
    11
    Dodge Pick-up
    130
    12
    BMW Sedan
    160
    13
    Audi Supercar
    226
    14
    BMW Supercar
    160
    Dave

  4. #4
    Registered User
    Join Date
    11-11-2015
    Location
    Chicago, Illinois
    MS-Off Ver
    2007
    Posts
    29

    Re: Order Issue? Index Table Chooses The First Option When Two Rows Have Same Result

    Quote Originally Posted by Tony Valko View Post
    Enter this formula in H2:

    =IFERROR(LARGE(IF(ISNUMBER(MATCH(B$2:B$13,E$2:E$4,0)),C$2:C$13),ROWS(H$2:H2)),"")

    Enter this formula in G2:

    =IF(H2="","",INDEX(B:B,SMALL(IF(ISNUMBER(MATCH(B$2:B$13,E$2:E$4,0))*(C$2:C$13=H2),ROW(B$2:B$13)),COUNTIF(H$2:H2,H2))))

    Enter this formula in F2:

    =IF(H2="","",INDEX(A:A,SMALL(IF(ISNUMBER(MATCH(B$2:B$13,E$2:E$4,0))*(C$2:C$13=H2),ROW(B$2:B$13)),COUNTIF(H$2:H2,H2))))

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

    Select F2:H2 and copy down until you get a row full of blanks.
    At first I thought that indexing a column wouldn't work. This is the first of many tables replicated downwards, so imagine 5, 20, or more of these. However, the information is the same in each column, so it could.

    I was able to make it work in a simple "2-story" stack. I'll look at what FlameRetired as to say before declaring this solved, though. Your solution can work, so I appreciate the time and effort, thank you.

  5. #5
    Registered User
    Join Date
    11-11-2015
    Location
    Chicago, Illinois
    MS-Off Ver
    2007
    Posts
    29

    Re: Order Issue? Index Table Chooses The First Option When Two Rows Have Same Result

    Quote Originally Posted by FlameRetired View Post
    Slightly different approach.

    In H2 array-enter this formula and fill down.
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Then in E2 array-enter this fill down and across to column G.
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Row\Col
    A
    B
    C
    D
    E
    F
    G
    H
    1
    Make Model Top Speed
    helper
    2
    Chrysler Coupe
    120
    BMW Sedan
    160
    160
    3
    Dodge 4-door
    130
    Chevy 4-door
    150
    150
    4
    Ford Sedan
    123
    Pontiac 4-door
    142
    142
    5
    Chevy 4-door
    150
    Ford Electric
    133
    133
    6
    Pontiac 4-door
    142
    Dodge Sedan
    130
    130
    7
    Dodge Sedan
    130
    Dodge 4-door
    130
    130
    8
    Ford Electric
    133
    Ford Sedan
    123
    123
    9
    Chevy Convertible
    153
    10
    Pontiac 4x4
    142
    11
    Dodge Pick-up
    130
    12
    BMW Sedan
    160
    13
    Audi Supercar
    226
    14
    BMW Supercar
    160
    Is there a reason I need the helper column and just can't use it? I could copy the second formula over twice/two columns and not worry about the duplicate value, right? Or am I missing something?

  6. #6
    Registered User
    Join Date
    11-11-2015
    Location
    Chicago, Illinois
    MS-Off Ver
    2007
    Posts
    29

    Re: Order Issue? Index Table Chooses The First Option When Two Rows Have Same Result

    FlameRetired, thank you immensely. Tony Valko, your solution, while viable, is tad more complex. Both work well and are robust.

    Thank you both for the time and knowledge.

  7. #7
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Order Issue? Index Table Chooses The First Option When Two Rows Have Same Result

    You are welcome. Thank you for the feedback.

  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: Order Issue? Index Table Chooses The First Option When Two Rows Have Same Result

    You're welcome. 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. Replies: 4
    Last Post: 09-09-2014, 05:35 AM
  2. Replies: 10
    Last Post: 05-22-2014, 06:44 AM
  3. How to re-order the columns and rows in a pivot table - Excel 2010
    By Mirisage in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 04-15-2013, 08:35 AM
  4. Issue with deleting specific rows from a table.
    By skonduru in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-28-2012, 12:10 PM
  5. index match result issue
    By cedarhill in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-20-2011, 01:18 PM
  6. Multiple rows make a single order and Pivot table
    By saurya_s in forum Excel General
    Replies: 5
    Last Post: 10-30-2008, 01:51 PM
  7. [SOLVED] How do I change order of rows in pivot table?
    By greghenry in forum Excel General
    Replies: 2
    Last Post: 03-28-2006, 09:45 AM

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