+ Reply to Thread
Results 1 to 3 of 3

How to get a value in a square matrix with two conditions

  1. #1
    Registered User
    Join Date
    10-09-2019
    Location
    Auckland, New Zealand
    MS-Off Ver
    Office 365
    Posts
    2

    How to get a value in a square matrix with two conditions

    Hi guys,

    I have a square matrix that represents the distances between over 1500 places.
    The first column is a transpose of the first row. So it's possible to see every distance between the different places.
    What I'm trying is: when I choose one place, I need to find the closest one. As it's a square matrix, there is a diagonal with 0s, which represents the distance between the same place.

    I tried this formula
    {=INDEX(A2:A6,MATCH(MIN(IF(B1:F1=H4,IF(B2:F6>0,B2:F6))),0))}
    , where H2 is the origin, A2:A6 is the destiny. But it's not working.

    Does someone have another idea for this puzzle?

    I attached an example.

    Kind Regards,
    Alex
    Attached Files Attached Files
    Last edited by alexlutz; 10-09-2019 at 08:12 PM.

  2. #2
    Valued Forum Contributor loginjmor's Avatar
    Join Date
    01-31-2013
    Location
    Cedar Rapids, Iowa
    MS-Off Ver
    Excel 2013
    Posts
    1,073

    Re: How to get a value in a square matrix with two conditions

    Hi -

    If you put this formula into cell I4, it should give you the closest destination to the input location.

    =INDEX(B1:F1,1,MATCH(H5,OFFSET($A$1,MATCH(H4,A:A,0)-1,1,1,5),0))

    This just uses the OFFSET function to crate an array of 5 values based on the row found by the inner MATCH function, and the column found by the outer MATCH function. Then INDEX just uses those columns to find the correct destination in the top row.

    I hard coded in the 5 columns in the OFFSET function. If you have a set number of columns, you can either swap that number into hte formula, or you could use the COUNT function nested in there to determine how wide the array should be.

    Hope this helps.
    ____________________________________________
    If this has solved your problem, please edit the thread title to add the word [SOLVED] at the beginning. You can do this by
    -Go to the top of the first post
    -Select Thread Tools
    -Select Mark thread as Solved

    If I have been particularly helpful, please "bump" my reputation by pressing the small star in the lower left corner of my post.

  3. #3
    Registered User
    Join Date
    10-09-2019
    Location
    Auckland, New Zealand
    MS-Off Ver
    Office 365
    Posts
    2

    Re: How to get a value in a square matrix with two conditions

    Brilliant. Exactly what I need.

    Thank you so much.

+ 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. square matrix determinant
    By handa in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-05-2018, 09:02 PM
  2. [SOLVED] sum in matrix if conditions
    By xlepws in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 11-06-2017, 05:23 AM
  3. Create a r-square matrix on simple strings of values
    By guillm in forum Excel General
    Replies: 5
    Last Post: 11-15-2016, 05:25 AM
  4. [SOLVED] convert square meters to square feet
    By mroberts in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-07-2013, 12:51 PM
  5. Replies: 3
    Last Post: 08-19-2009, 08:53 AM
  6. how to center a square plot area in a square chart
    By xppuser in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 03-11-2006, 04:20 AM
  7. [SOLVED] Regression Output -- R Square versus Adjusted R Square
    By Bonnie in forum Excel General
    Replies: 1
    Last Post: 10-24-2005, 08:05 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