+ Reply to Thread
Results 1 to 6 of 6

Modify formula based on first non-negative number in a row

Hybrid View

  1. #1
    Registered User
    Join Date
    08-02-2004
    Posts
    59

    Modify formula based on first non-negative number in a row

    I'm trying to calculate CAGR for a row of 10 values using a standard formula: =RATE($K$1-$B$1,0,-B2,K2)

    The first row has years, so K1 = 2011 and B1 = 2002, therefore the # of periods is 9.

    This formula works fine if B2 is a positive number. However, it returns an error if B2 is negative, as the rate formula must start with a positive number. Is there some way to modify the above formula to start with the first non-negative value?

    So if the row is:
    -1, 2, 3 .... 10 then the formula would be =RATE($K$1-$C$1,0,-C2,K2). This ensures that both the # of periods & the starting period match up.

    However, if the row is:
    -1, -2, 3 ... 10, then the formula would be =RATE($K$1-$D$1,0,-D2,K2), basically, the formula would adjust over two columns so it starts with 3 as the beginning value.

    Any suggestions are much appreciated.

    Thanks.

  2. #2
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: Modify formula based on first non-negative number in a row

    Perhaps ..

    =RATE($K$1-INDEX($B$1:$I$1,MATCH(TRUE,INDEX(B2:I2>0,0),0)),0,INDEX(B2:I2,MATCH(TRUE,INDEX(B2:I2>0,0),0)),K2)

    where Col B to Col I store your positive/negative values

    ---------- Post added at 11:04 AM ---------- Previous post was at 11:03 AM ----------

    Perhaps ..

    =RATE($K$1-INDEX($B$1:$I$1,MATCH(TRUE,INDEX(B2:I2>0,0),0)),0,INDEX(B2:I2,MATCH(TRUE,INDEX(B2:I2>0,0),0)),K2)

    where Col B to Col I store your positive/negative values. This will work based on the first positive number
    Life's a spreadsheet, Excel!
    Say thanks, Click *

  3. #3
    Registered User
    Join Date
    08-02-2004
    Posts
    59

    Re: Modify formula based on first non-negative number in a row

    Thank you but I keep getting a NUM error using that formula (might be my fault, only 9 numbers in total).

    Attaching a sample spreadsheet which should hopefully help clarify.

    Sample.xlsx

  4. #4
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: Modify formula based on first non-negative number in a row

    Tweaked the formula based on your row refernces...

    =RATE($K2-INDEX($B2:$K2,MATCH(TRUE,INDEX(B3:K3>0,0),0)),0,-INDEX(B3:K3,MATCH(TRUE,INDEX(B3:K3>0,0),0)),K3)

    See attached too..
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    08-02-2004
    Posts
    59

    Re: Modify formula based on first non-negative number in a row

    Perfect thank you!

  6. #6
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Modify formula based on first non-negative number in a row

    @ DrSues02

    Based on your last post it seems that you are satisfied with the solution(s) you've received but you haven't marked your thread as SOLVED. I'll do that for you now but please keep in mind for your future threads that Rule #9 requires you to do that yourself. If your problem has not been solved you can use Thread Tools (located above your first post) and choose "Mark this thread as unsolved".
    Thanks.

+ 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