Recently in my consulting role I came across a not so uncommon question which required me to find the intersection of an unknown Curve with the axis ie: At what date will the project break-even?
Today in Formula Forensics we are going to look at 3 ways to tackle this problem.
The Problem
The question that was posed was “What is the payback period for the project?”
That is at what point (date or time period) is the Cumulative Cash Flow = 0
The cash flow model is summarised below:
The pay-back period is defined as the time it takes for the cumulative cash flow to return to zero.
We can see in the table above that it is between 2015 and 2016, and that it will be closer to 2016 than 2015.
Today I will explain 3 techniques for determining what the pay-back period is.
These 3 techniques are:
- Manual Estimation,
- Equal Triangles Solution
- Forecast Formula Solution
As usual at Formula Forensics you can follow along by downloading the sample worksheet here: Excel 97-13
Manual Estimation
Looking at the data table we can see that the Cumulative Cash Flow will return to zero in the later half of 2015.
We can fairly accurately determine this by plotting a chart of the data
We can see here that the line of the Cumulative Cash Flow passes through the X Axis in the October – November period.
We can do a few things to improve our estimate
Firstly add Months as a Minor Unit to the X-Axis
Now Zoom in
We can see that the Cumulative Cash Flow line (Blue) crosses the axis at about the 15th October.
This is 9.5 months into 2015 or 9.5/12 = 0.792 of a year.
Therefor the payback period of the project will be 2.792 Years
Equal Triangles Solution
The easiest method of determining the exact value is to use the Rule of Triangles, which says the ratio of two sides in two similar triangles is the same.
In our case we can form two triangles
Where 9/x = 11.5/365
This can be re-arranged for x as x = (365 x 9)/11.5
x = 285.65 days
or 285.65 = 0.783 Years
Luckily Excel is great at adding dates and days
In a cell type = Date(2015,1,1)+ 285.65
Excel returns 13 Oct 2015
So our pay-back period is 2.78 years
Instead of doing this manually we can write this as a formula in Excel
In a spare cell, say D36 put: =(F4-E4)*(0-E6)/(F6-E6)
Excel displays 285.652 Days
Or as years, in say D37: =2+(0-E6)/(F6-E6)
Excel displays 2.783 Years
We have to remember that the project started 2 years before 2015 and so the payback is 2.783 years.
Forecast Formula Solution
Many years ago I stumbled onto a neat web site, http://stackoverflow.com/. The site offers many solutions to various computing problems not just Excel.
Specifically they had answered a similar question about interpolating data points http://stackoverflow.com/questions/1043513/interpolating-data-points-in-excel and specifically the third post which has a formula based solution.
I have used this formula many times in my work roles and here at Chandoo.org Forums and I have seen it used by Faseeh and others as well.
Converting their formula to a Horizontal Range for my cash flow model yields a solution:
=FORECAST(0, OFFSET(C4 , , MATCH(0, C6:G6)-1, 1, 2), OFFSET(C6 , , MATCH(0, C6:G6)-1, 1, 2))
Which we will now pull apart.
The formula =FORECAST(0, OFFSET(C4 , , MATCH(0, C6:G6)-1, 1, 2), OFFSET(C6 , , MATCH(0, C6:G6)-1, 1, 2))
The formula, which appears complex at first, is simply a Forecast() function with other formulas for the Forecast components
=FORECAST(0, OFFSET(C4,,MATCH(0,C6:G6)-1,1,2), OFFSET(C6,,MATCH(0,C6:G6)-1,1,2))
The Excel Forecast() function uses the following syntax:
In our example
X: 0
Known Y’s: OFFSET(C4,,MATCH(0,C6:G6)-1,1,2)
Known X’s: OFFSET(C6,,MATCH(0,C6:G6)-1,1,2)
You can see directly above that the two Offset formulas in the Known X’s and Known Y’s are exactly the same except that the first refers to the data in Row 4 (The Dates) and the second the data in Row 6 (The Values).
The Forecast() function will return an estimate of Y for a known value of X which is interpolated in the arrays of Known X and Known Y. Forecast uses a least squares method of modelling to form a line of best fit modelling the data.
It is possible to trick Forecast() by not supplying an Array of Data but simply supplying a subset of data which are the points on either side of our known Y value. This is done by using the Offset() function and is described below.
In addition we swap the X and Y values as we are after an unknown X value in our model, knowing Y=0, so by swapping the X and Y values fed into the Forecast() function, Forecast will find the X value which is our required Date.
Going back to the formula:
=FORECAST(0, OFFSET(C4,,MATCH(0,C6:G6)-1,1,2), OFFSET(C6,,MATCH(0,C6:G6)-1,1,2))
We can see that forecast is going to return a Y Value for an X value of 0 where the Known Y’s: are OFFSET(C4,,MATCH(0,C6:G6)-1,1,2) , and Known X’s: OFFSET(C6,,MATCH(0,C6:G6)-1,1,2)
Lets look at the Known Y’s
OFFSET(C4,,MATCH(0,C6:G6)-1,1,2)
This is an Excel Offset() function. Offset() has the syntax:
In the example: OFFSET(C6, , MATCH(0,C6:G6)-1, 1, 2)
Reference: C6
Rows: Blank = 0
Columns: MATCH(0,C6:G6)-1
Height: 1
Width: 2
Offset will return a range which is offset from C6 by 0 Rows vertically and MATCH(0,C6:G6)-1 columns and will be 1 Row high and 2 Column Wide.
The section MATCH(0,C6:G6)-1, returns the index number of the location of 0 in the range C6:G6 and subtracts one from that value.
Because Match will not find 0 in the range C6:G6 it will return the location of the next value which is lower than 0 or the position of -9 in our example which is Position 3, subtracting 1 from that to = 2
So our offset formula is now read as
OFFSET(C6, , MATCH(0,C6:G6)-1, 1, 2)
OFFSET(C6, , 2, 1, 2)
We can check this by wrapping the Offset() function in a Sum() function
In cell D48 enter: =SUM(OFFSET(C6,,MATCH(0,C6:G6)-1,1,2))
Or you can enter it as =OFFSET(C6,,2,1,2)
Excel will return -6.5 which is the sum of -9.0 and 2.5
That is explained as Offset cell C6, 0 rows down and 2 Columns to the right (C6 becomes E6) and make the new range 2 cells wide 1 cell high (E6 becomes E6:F6).
We can now see that this returns the two cells that straddle across the Zero position as a Range to the Forecast() function.
Similarilly we can see that the Dates are returned as the Y Values to the Forecast() function by use of the similar: OFFSET(C4,,MATCH(0,C6:G6)-1,1,2) function that will convert to E4:F4
Chandoo has written a neat post on how Offset works at: http://chandoo.org/wp/2012/09/17/offset-formula-explained/
Finally we go back to the Forecast() function and see that:
=FORECAST(0, OFFSET(C4,,MATCH(0,C6:G6)-1,1,2), OFFSET(C6,,MATCH(0,C6:G6)-1,1,2))
Is the same as
=FORECAST(0, E4:F4, E6:F6)
In a spare cell, D50 type: =FORECAST(0, E4:F4, E6:F6)
Excel returns 13 Oct 15, our Break-even date.
We can calculate the number of years that this is by subtracting the start date and diving the answer by 365 days:
=(FORECAST(0,OFFSET(C4,,MATCH(0,C6:G6)-1,1,2),OFFSET(C6,,MATCH(0,C6:G6)-1,1,2))-C4)/365
In cell D42, type: =(FORECAST(0,OFFSET(C4,,MATCH(0,C6:G6)-1,1,2),OFFSET(C6,,MATCH(0,C6:G6)-1,1,2))-C4)/365
Excel returns 2.78, which is 2.78 years.
Download
You can download a copy of the above file and follow along, Download Here – Excel 2007-2013.
Other Chandoo.org Posts related to Interpolation
Here at Chandoo.org you can find the following related posts related to Interpolation:
http://chandoo.org/wp/2011/01/24/trendlines-and-forecasting-in-excel/
http://chandoo.org/wp/2011/01/26/trendlines-and-forecasting-in-excel-part-2/
http://chandoo.org/wp/2011/01/27/trendlines-and-forecasting-in-excel-part-3/
Narayank used an Equal Triangles approach to solve: http://chandoo.org/forums/topic/interpolate-a-number-in-between-two-numbers (post 2)
Faseeh then used a Forecast() formula approach as described above, to the same problem (Post 3).
Final Thoughts
There are many other ways to interpolate values along a series.
I would love to hear about some of your interpolation experiences, techniques or uses
Lets us know in the comments below:
Formula Forensics “The Series”
This is the 33rd post in the Formula Forensics series.
You can learn more about how to pull Excel Formulas apart in the following posts: Formula Forensic Series
Formula Forensics Needs Your Help
I need more ideas for future Formula Forensics posts and so I need your help.
If you have a neat formula that you would like to share like above, try putting pen to paper and draft up a Post like above or;
If you have a formula that you would like explained, but don’t want to write a post, send it to Hui or Chandoo.
























24 Responses
I’d suggest simply using the subtotal function and filtering the data using the Win/Loss column. You get the same results and the formula is more comprehensible.
@John
That is one option.
There are times however when you want to see the whole data table or a filtered subset and still want to produce summary reports against an unfiltered field.
Is there a particular reason why you are using a comma and the unary (–) operator for the second array in the SUMPRODUCT formula? It seems to work the same if you were to string the arrays together using the asterisk (*). The advantage is that SUMPRODUCT treats the entire string of arrays as a single array.
@Mathew
Your correct, There is no difference.
I thought it may have been easier to explain this method.
Is there a way to do this on a large set of data? As in ~100,000 rows? When I try I get an error because the formula becomes too long. It says the max length of a formula is 8,192 characters. Excel 2010.
How do I incorporate a specific text within a cell for the second array. For instance, – -(C7:C13=”Apple”)
when I chose a specific text the formula does not work.
@RB
I am not sure what is the issue as if I use the sample data in the post the following work fine
Count:
=SUMPRODUCT(SUBTOTAL(3,OFFSET(C7:C13,ROW(C7:C13)-MIN(ROW(C7:C13)),,1)), –(C7:C13=”L”))
Sum:
=SUMPRODUCT(SUBTOTAL(3,OFFSET(C7:C13,ROW(C7:C13)-MIN(ROW(C7:C13)),,1)),(C7:C13=”L”)*(D7:D13))
You may want to check that there are no leading or trailing spaces in your list of Apples
I should have given a better explanation. Heres my situation. I have a column with cells filled with names like Column 1, Column 2, Pier 1, Pier 2, etc. If the cell just contained Pier and searched for that it works. But because it has other characters in the cell its not recognizing the pier. So how can I extract specific characters of a string of text in this formula?
Hopefully this was a better explanation
Hello-
This formula works pretty well for me except that it slow down excel and prevents some of my macros from working. I was wondering if there was a way to program this in VBA so that excel isn’t always trying to recalculate it. I would like to use a push of a button to get it to run then paste in a cell.
Thanks!
I am trying to sum filtered data in a column, but would want to ignore the negative values in the column. How to go about doing this?
@Akshay
Why not just add a filter to that column to only show the values greater than zero?
The negative values are required for reporting purposes, but their effect on the total is distorting the required output. Please advise.
@Akshay
I’d suggest making a post in the Chandoo.org Forums
http://forum.chandoo.org/
Attach a sample file to simplify the task
I have this working for counting and summing, however, I have a list and for the second array, I need a criteria. That is, I’m looking for b13:b200=”01.??.??” or =left((a1,2) or something like that. These types of criteria matches do not appear to work as I get a blank as a result.
Thanks!
@Bob
As your formula b13:b200=”01.??.??” looks like you are trying to check the first day of the month of the range
What about trying Day(B13:B200)=1
Hai Experts,
i understood this formula well and working fine in MS Excel 2013
but when the same am trying to place in google Spreadsheet it shows error as
“SUMPRODUCT has mismatched range sizes. Expected row count: 1. column count: 1. Actual row count: 2014, column count: 1.” and as a result #VALUE! Appears in cell.
Can anyone please help me how would i get it done in Google Spread sheet
or is there any other formula as a substitute for this.
Thank you very much.
thanks for providing this.. but why does excel keeps on prompting Circular referencing in cell D3?
@Vivek
I don’t know
I just downloaded the file and it is working fine and not showing that error
Goto the Formulas, Calculation Options Tab and check that Calculation is set to Automatic
What version of Excel and Windows are you using ?
I know that this forum is for MS Excel, but I am trying to help someone who is working in Google Sheets. The below formula works in Excel but Google Sheets returns:
“SUMPRODUCT has mismatched range sizes. Expected row count: 1. column count: 1. Actual row count: 39000, column count: 1.” and as a result #VALUE! Appears in cell.
This is the same problem asked by Srichirin above. Does anyone know if there is a formula for Google Sheets that will replicate what MS Excel does?
=SUMPRODUCT(SUBTOTAL(3,OFFSET($C$6:$C$39500,ROW($C$6:$C$39500)-MIN(ROW($C$6:$C$39500)),,1)),- -($C$6:$C$39500=H1),($D$6:$D$39500))
Trying to find a SUMPRODUCT formula that counts the word Closed by date for the last 7 days in a filtered list.
=COUNTIF(M:M,”>”&TODAY()-7) works ok for unfiltered count Column M contains Closure dates (blank if open) and Column L is Status Open or Closed
@ Terry
Please ask the question at the Chandoo.org Forums
https://chandoo.org/forum/
Please attach a sample file to ensure a quicker more accurate answer
I used this formula and worked like a charm! But, now I’ve been requested to use it but adding not one but two criteria in the same formula. For instance the sum I was doing added negative and positive numbers. I’ve been asked to use the exact same formula but adding that only positive numbers were considered… any idea on how to do this?
How exactly do you do sum filtered cells when two criteria are need not just one?
Thank you so much brother literally I have been struggling since morning to get the sum of the filtered category, however, after reading your blog attentively i got my solution, so thanks a lot once again.