+ Reply to Thread
Results 1 to 7 of 7

Best way to return a row number from MIN array formula

  1. #1
    Registered User
    Join Date
    10-03-2014
    Location
    Wisconsin
    MS-Off Ver
    2013
    Posts
    15

    Best way to return a row number from MIN array formula

    Hi!

    I have the following formula:

    {=MIN(IF(M2=Product,IF(AM2=PatientID,IF(ROW(L2)<>ROW(FillDate),IF(L2<=FDate,FDate)))))}

    This returns the next subsequent date (Column L) given the conditions as set forth. I want it to return the row number of that date, however. There are duplicate dates throughout the sheet. The only way I could figure out how to do it was by using the following formula:

    {=IFERROR(MATCH(MIN(IF(M2=Product,IF(AM2=PatientID,IF(ROW(L2)<>ROW(FDate),IF(L2<=FDate,FDate))))),IF(M2=Product,IF(AM2=PatientID,IF(ROW(L2)<>ROW(FDate),IF(L2<=FDate,FDate)))),0)+1,"")}

    This, in essence, doubles the amount of time by calculating the array twice. Is there any way to just return the row number using the first formula, other than calculating a whole duplicate array?

  2. #2
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Best way to return a row number from MIN array formula

    Hi.

    If you could attach a workbook with an example and your expected results then I'm sure we'll be able to help.

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  3. #3
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,732

    Re: Best way to return a row number from MIN array formula

    I presume FDate is a named range of dates, so if these are in sequence down the column, you could try using ROW(FDate) instead as the final term in your first formula, and then the MIN function will find the smallest row that contains the date. Note that you might need to subtract the number of rows above the table if you want the relative row number (as MATCH would return).

    Hope this helps.

    Pete

  4. #4
    Registered User
    Join Date
    10-03-2014
    Location
    Wisconsin
    MS-Off Ver
    2013
    Posts
    15

    Re: Best way to return a row number from MIN array formula

    Quote Originally Posted by Pete_UK View Post
    I presume FDate is a named range of dates, so if these are in sequence down the column, you could try using ROW(FDate) instead as the final term in your first formula, and then the MIN function will find the smallest row that contains the date. Note that you might need to subtract the number of rows above the table if you want the relative row number (as MATCH would return).

    Hope this helps.

    Pete
    Thank you, unfortunately they are not in sequence. I realize I could sort them, but I'm trying to come up with a template that will be used by numerous people without any user assistance other than copying and pasting the initial data (thus, sorting is out of the question). If I use row(FDate) it seems to just return the smallest row number on the array.

  5. #5
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,732

    Re: Best way to return a row number from MIN array formula

    Quote Originally Posted by wallock View Post
    ... it seems to just return the smallest row number on the array ...
    Well, yes, it only works if the dates are in sequence, which you now say is not the case. Please attach a sample workbook, as XOR LX has requested.

    Pete

  6. #6
    Registered User
    Join Date
    10-03-2014
    Location
    Wisconsin
    MS-Off Ver
    2013
    Posts
    15

    Re: Best way to return a row number from MIN array formula

    Sample2.xlsx

    Alright, the sample document should be attached with the current working formula. Let me know if you have any questions and thank you greatly for taking a look.

  7. #7
    Registered User
    Join Date
    10-03-2014
    Location
    Wisconsin
    MS-Off Ver
    2013
    Posts
    15

    Re: Best way to return a row number from MIN array formula

    Quote Originally Posted by wallock View Post
    Attachment 356277

    Alright, the sample document should be attached with the current working formula. Let me know if you have any questions and thank you greatly for taking a look.
    Any thoughts?

+ 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. Return relative position of the largest number in an array
    By DanielMinh in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-20-2013, 03:01 AM
  2. Return row & column number from cell in 2d array
    By ranald in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 03-13-2013, 05:27 PM
  3. Replies: 0
    Last Post: 08-03-2011, 03:01 PM
  4. Replies: 3
    Last Post: 06-09-2011, 02:47 PM
  5. Replies: 13
    Last Post: 12-03-2010, 10:39 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