+ Reply to Thread
Results 1 to 10 of 10

A complicated reverse lookup formula

  1. #1
    Registered User
    Join Date
    07-09-2014
    Location
    USA
    MS-Off Ver
    2010
    Posts
    3

    A complicated reverse lookup formula

    So I have monthly cashflows for 7 years. I have it so that month's cash flows adds on to the previous month's. I need a formula (or two) that can return the column and row labels for when the first non-zero number appears.

    2014 2015 2016 2017 2018 2019 2020
    Jan $(100) $(1,300) $(2,390) $(2,260) $(1,940) $(740) $460
    Feb $(200) $(1,400) $(2,380) $(2,240) $(1,840) $(640) $560
    Mar $(300) $(1,500) $(2,370) $(2,220) $(1,740) $(540) $660
    Apr $(400) $(1,600) $(2,360) $(2,200) $(1,640) $(440) $760
    May $(500) $(1,700) $(2,350) $(2,180) $(1,540) $(340) $860
    Jun $(600) $(1,800) $(2,340) $(2,160) $(1,440) $(240) $960
    Jul $(700) $(1,900) $(2,330) $(2,140) $(1,340) $(140) $1,060
    Aug $(800) $(2,000) $(2,320) $(2,120) $(1,240) $(40) $1,160
    Sep $(900) $(2,100) $(2,310) $(2,100) $(1,140) $60 $1,260
    Oct $(1,000) $(2,200) $(2,300) $(2,080) $(1,040) $160 $1,360
    Nov $(1,100) $(2,300) $(2,290) $(2,060) $(940) $260 $1,460
    Dec $(1,200) $(2,400) $(2,280) $(2,040) $(840) $360 $1,560

    So in this example, I would need a formula that could find the first number above $0 (in this case it is $60) and return the month and year (Sep 2019)

    Any help would be amazing!

  2. #2
    Forum Expert
    Join Date
    10-09-2012
    Location
    Dallas, Texas
    MS-Off Ver
    MO 2010 & 2013
    Posts
    3,049

    Re: A complicated reverse lookup formula

    First off, I reccomend attaching a sample workbook instead of pasting to the forum like above. Second post a desired end state in the example so we can understand what you are trying to accomplish. You are much more likely to get specific help .

    I would try but I need a few examples to understand what answer youa re trying to get at. I can find the first non negative datapoint in each row, but I am nbot sure if that is what you are trying to get at.
    Please ensure you mark your thread as Solved once it is. Click here to see how.
    If a post helps, please don't forget to add to our reputation by clicking the star icon in the bottom left-hand corner of a post.

  3. #3
    Registered User
    Join Date
    07-09-2014
    Location
    USA
    MS-Off Ver
    2010
    Posts
    3

    Re: A complicated reverse lookup formula

    Sorry, didn't see that you could post an attachment!

    I'm able to find the minimum value above zero by using the array function in the attached workbook. I want to know what month and year represents the first number above zero. The difficulty is that it could be in any row or column (different products have numbers).
    Attached Files Attached Files

  4. #4
    Valued Forum Contributor Miraun's Avatar
    Join Date
    04-03-2009
    Location
    New England
    MS-Off Ver
    2003, 2007, 2010, 2013
    Posts
    554

    Re: A complicated reverse lookup formula

    Would you be open to using user defined functions to achieve this goal?

    It would require a file extension change from XLSX to XLSM... Dunno the requirements, so I'd rather ask before assuming that you're fine with VBA.
    Going for Guru! Click the Star to the bottom left of this post if I helped!

  5. #5
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: A complicated reverse lookup formula

    For month use this array formula (based on your value cell E17): =INDIRECT("A" &MIN(IF(B3:H14=E17,ROW(B3:H14),"")))

    For the year, try this array formula: =INDIRECT("R1" & "C" & MIN(IF(B3:H14=E17,COLUMN(B3:H14),"")),FALSE)

    I'm not sure if you need to have it in one cell, but those should be the pieces needed to get you started. I realize you know, but other readers might not, remember to press cntrl+shift+enter after writing the formulas to get the "array" magic to happen.
    Attached Files Attached Files
    Last edited by GeneralDisarray; 07-09-2014 at 11:30 AM.
    Remember, saying thanks only takes a second or two. Click the star icon(*) below the post you liked, to give some Rep if you think an answer deserves it.

    Please,mark your thread [SOLVED] if you received your answer.

  6. #6
    Valued Forum Contributor Miraun's Avatar
    Join Date
    04-03-2009
    Location
    New England
    MS-Off Ver
    2003, 2007, 2010, 2013
    Posts
    554

    Re: A complicated reverse lookup formula

    Please Login or Register  to view this content.
    Where you use Miraun(A1:H14)
    However, with the example you gave, there's a little complexity with the hidden row2... don't know if that will be consistent or not, because otherwise the first entry under 2016 gets hit.

  7. #7
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: A complicated reverse lookup formula

    I see, you need it in one cell. You don't need VBA for this.

    REMEMBER, confirm this with "cntrl+shift+enter"

    =INDIRECT("A" &MIN(IF(B3:H14=MIN(IF(B3:H14>0,B3:H14)),ROW(B3:H14),""))) & " - " &INDIRECT("R1" & "C" & MIN(IF(B3:H14=MIN(IF(B3:H14>0,B3:H14)),COLUMN(B3:H14),"")),FALSE) & ": $" &MIN(IF(B3:H14>0,B3:H14))

    That will give you this: Sep - 2019: $60. I thought you might like the month, a little dash, then the value.
    Attached Files Attached Files

  8. #8
    Valued Forum Contributor Miraun's Avatar
    Join Date
    04-03-2009
    Location
    New England
    MS-Off Ver
    2003, 2007, 2010, 2013
    Posts
    554

    Re: A complicated reverse lookup formula

    Hi General;

    Your equation is amazing, however, there are two concerns with the result:
    1) It's identifying the lowest positive value, not necessarily the first occurrence of positive.
    2) If two identical values are identified, it will utilize the minimum of Year, and minimum of month. Therefore if you have January 2018 and December 2014 with values of $10, it'll return January 2014. (this was the main factor that I felt I could not overcome, and why I deferred to a UDF)

  9. #9
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: A complicated reverse lookup formula

    Your UDF is perfectly acceptable - We posted concurrent answers to the same question and I was just trying to play out the solution for educational purposes.

    Miraun, the duplicated values do lead to problems. But for the application shown here, a duplicate will not occur.



    OP - you can greatly simplify this by abandoning the "matrix" style for the data entry, and use a simpler 3 column table (year,month,value) with a related Pivot table for presentation (see attached).

    See the attached for a simple example of what I mean. By placing the dollar values in one column you totally eliminate the problem pointed out by Miraun.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    07-09-2014
    Location
    USA
    MS-Off Ver
    2010
    Posts
    3

    Re: A complicated reverse lookup formula

    Wow! You are all truly amazing! Thanks for all of the input. I figured it out and would definitely not have been able to without all of your help. Thank you!

+ 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. Match/Index/Lookup - Searching From Bottom to Top (A reverse lookup maybe)
    By Neutralizer in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-02-2013, 03:55 AM
  2. Replies: 3
    Last Post: 07-19-2012, 01:26 PM
  3. Max reverse lookup
    By TMPAPA in forum Excel General
    Replies: 4
    Last Post: 01-30-2010, 06:26 AM
  4. Complicated lookup formula
    By cloudfrog in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-19-2008, 11:45 AM
  5. Reverse Lookup help
    By bras1l in forum Excel General
    Replies: 1
    Last Post: 10-30-2006, 02:13 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