+ Reply to Thread
Results 1 to 10 of 10

Matrix 2-Way Lookup

  1. #1
    Registered User
    Join Date
    06-11-2011
    Location
    Québec, Canada
    MS-Off Ver
    Excel 2010
    Posts
    19

    Matrix 2-Way Lookup

    Hi guys,

    I am trying to put the coordinates of values placed inside a matrix in increasing order. I have put the matrix values into a column in increasing order I am now looking for a formula that could return the coodinates of each values. I have plugged in an array formula that does return values that look like the coordinates I am looking for but in a special date format.

    I have played around with the formula but had no success in obtaining the raw coordinates from it.

    Attached is the example with the table of what I am getting and what I would like to get from this array formula.

    Any help would be greatly appreciated,

    Thanks

    Adam
    Attached Files Attached Files

  2. #2
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Matrix 2-Way Lookup

    Hi Adam Beauregard,



    =IF(COLUMNS($B3:B3)<=$L3,INDEX($A$3:$A$12,MATCH($M3,INDEX($B$3:$K$12,0,SMALL(IF($B$3:$K$12=$M3,COLUMN($B$2:$K$2)-COLUMN($B$2)+1),COLUMNS($B3:B3))),0)),"")&","&IF(COLUMNS($N3:N3)<=$L3,INDEX($B$2:$K$2,,SMALL(IF($B$3:$K$12=$M3,COLUMN($B$2:$K$2)-COLUMN($B$2)+1),COLUMNS($N3:N3))),"")


    with Ctrl + Shift + Enter
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  3. #3
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Matrix 2-Way Lookup

    or to reverse the result

    =IF(COLUMNS($N3:N3)<=$L3,INDEX($B$2:$K$2,,SMALL(IF($B$3:$K$12=$M3,COLUMN($B$2:$K$2)-COLUMN($B$2)+1),COLUMNS($N3:N3))),"") & ","& IF(COLUMNS($B3:B3)<=$L3,INDEX($A$3:$A$12,MATCH($M3,INDEX($B$3:$K$12,0,SMALL(IF($B$3:$K$12=$M3,COLUMN($B$2:$K$2)-COLUMN($B$2)+1),COLUMNS($B3:B3))),0)),"")

  4. #4
    Registered User
    Join Date
    06-11-2011
    Location
    Québec, Canada
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: Matrix 2-Way Lookup

    Thanks pike,

    I've arrived at something similar with the following formula (with which commas are not displayed in empty cells)

    =TEXT(IF(COLUMNS($F2:F2)<=$P2,INDEX($E$2:$E$11,MATCH($Q2,INDEX($F$2:$O$11,0,SMALL(IF($F$2:$O$11=$Q2,COLUMN($F$1:$O$1)-COLUMN($F$1)+1),COLUMNS($F2:F2))),0)),""),"#")&TEXT(IF(COLUMNS($R2:R2)<=$P2,INDEX($F$1:$O$1,,SMALL(IF($F$2:$O$11=$Q2,COLUMN($F$1:$O$1)-COLUMN($F$1)+1),COLUMNS($R2:R2))),""),",#")

    However, there is still a problem with either formulas: In cases where there are more than one occurence of the value, the formulas won't always return the appropriate second value's coordinates. It seems that if the vertical coordinate is not the same for the second value, it just returns the exact same coordinates.

    I've tried filling the other half of the matrix which does allow to formula to return the expected coordinates but not without returning duplicates and reversed results.

    Please find attached the same example with your formula plugged-in and my comments indicating where the coordinates returned are not as expected.
    Attached Files Attached Files

  5. #5
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Matrix 2-Way Lookup

    or

    =IF(COLUMNS($N4:N4)<=$L4,INDEX($B$2:$K$2,,SMALL(IF($B$3:$K$12=$M4,COLUMN($B$2:$K$2)-COLUMN($B$2)+1),L4)),"") & ","& IF(COLUMNS($B4:B4)<=$L4,INDEX($A$3:$A$12,MATCH($M4,INDEX($B$3:$K$12,0,SMALL(IF($B$3:$K$12=$M4,COLUMN($B$2:$K$2)-COLUMN($B$2)+1),L4)),0)),"")
    Attached Files Attached Files

  6. #6
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    Office 2021
    Posts
    2,237

    Re: Matrix 2-Way Lookup

    Since you are on XL2010, you can reduce the formula with IFERROR or AGGREGATE

    =IFERROR(INDEX($A$2:$K$2,SMALL(IF($B$3:$K$12=$M3,COLUMN($B$2:$K$2)),COLUMNS($N3:N3)))&","&INDEX($A:$A,SMALL(IF($B$3:$K$12=$M3,ROW($B$3:$B$12)),COLUMNS($N3:N3))),"")

    Or AGGREGATE will work WITHOUT Ctrl+Shift+Enter.

    =IFERROR(INDEX($A$2:$K$2,AGGREGATE(15,6,COLUMN($B$3:$K$12)/($B$3:$K$12=$M3),COLUMNS($N3:N3)))&","&INDEX($A:$A,AGGREGATE(15,6,ROW($A$3:$A$12)/($B$3:$K$12=$M3),COLUMNS($N3:N3))),"")

    Also, if you ever will not insert a column before A, you can use like INDEX($A$2:$K$2,,) this will avoid the column offset like -COLUMN($B2)+1
    Last edited by Haseeb Avarakkan; 12-01-2011 at 10:16 PM.
    Regards,
    Haseeb Avarakkan

    __________________________________
    "Feedback is the breakfast of champions"

  7. #7
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Matrix 2-Way Lookup

    True but

    =IF(COLUMNS($N4:N4)<=$L4,INDEX($B$2:$K$2,,SMALL(IF($B$3:$K$12=$M4,COLUMN($B$2:$K$2)-COLUMN($B$2)+1),L4)),"") & ","& IF(COLUMNS($B4:B4)<=$L4,INDEX($A$3:$A$12,MATCH($M4,INDEX($B$3:$K$12,0,SMALL(IF($B$3:$K$12=$M4,COLUMN ($B$2:$K$2)-COLUMN($B$2)+1),L4)),0)),"")
    Picks up the second value coordinates

  8. #8
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    Office 2021
    Posts
    2,237

    Re: Matrix 2-Way Lookup

    Hello,

    When you copy across this will pick up the 2nd, 3rd, 4th... instances.

    See the attached.
    Attached Files Attached Files

  9. #9
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Matrix 2-Way Lookup

    Haseeb A
    True ,I think Adam Beauregard wants it by rows?
    but in saying that he mighten have realised what his orgional forumla was doing

  10. #10
    Registered User
    Join Date
    06-11-2011
    Location
    Québec, Canada
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: Matrix 2-Way Lookup

    Very nice guys,

    Would it be possible to have all the coordinates in a single column. I recognize that my inital formula was not design for that but I now realize such display would ease my subsequent calculations.

    Also, the formula doesn't seem to be picking up well on the zero values as the coordinates returned are duplicated and are actually empty cells.

    Please refer the attachment to see exactly what display would be preferable for my situation.

    Thanks alot for everything!
    Attached Files Attached Files

+ 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