nested IF statements in a cash flow model

dmcelrath

New Member
Joined
Feb 27, 2018
Messages
6
I am building a cash flow model to determine my IRR depending on when I sell the investment.

The logic I am trying to follow for the equation is:
  • If current period is equal to harvest period, then populate the cell with the sell price minus the cash outflow for that period.
  • If current period is greater than harvest period, then populate the cell with 0.
  • If current period is less than harvest period, then populate the cell with the cash outflow for that period.

My Harvest Period is cell B11
My Current Period row ranges from 0:17 which equates to cells E2:V2
My cash flow if current period = harvest period ranges from E11:V11
My cash flow if current period > harvest period ranges from E12:V12
My cash flow if current period < harvest period ranges from E10:V10

(I only created these individual rows calculating my cash flow for each scenario for each period bc my equations were getting lengthy and I was trying to simplify the equation for troubleshooting)

My equation for Current Period 0 is: =IF($B$11=E2,E11,IF($B$11<E2,E12,E10))

I then copy and paste this into my subsequent periods.

What happens is I have my Harvest Period set at 4, and the equation works for Periods 0:4, then pulls 0 for Periods 5:9 like it should, but when I get to Periods 10:17 it pulls the value from row 10 like the current period < harvest period.

I've tried all sorts of things trying to figure this out and don't know what to do!

Can someone please help me?

I am happy to share the spreadsheet if that would make it easier, I just need some guidance on how to do that.
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Hi,

Place a space before and after all your < and > symbols in the formula for it to show properly.
 
Upvote 0
Sorry, not following your description to the formula.
Can you post a few lines of sample data and expected results with description.
 
Upvote 0
[TABLE="width: 500"]
<tbody>[TR]
[TD]Harvest Period (HP)[/TD]
[TD]4[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Current Period (CP)[/TD]
[TD]0[/TD]
[TD]1[/TD]
[TD]2[/TD]
[TD]3[/TD]
[TD]4[/TD]
[TD]5[/TD]
[TD]6[/TD]
[TD]...[/TD]
[TD]10[/TD]
[TD]11[/TD]
[/TR]
[TR]
[TD]CF if CP < HP[/TD]
[TD]0
[/TD]
[TD]-26216[/TD]
[TD]-26610[/TD]
[TD]-27018[/TD]
[TD]-27444[/TD]
[TD]-27887[/TD]
[TD]-28348[/TD]
[TD]...[/TD]
[TD]-30388[/TD]
[TD]-30951[/TD]
[/TR]
[TR]
[TD]CF if CP = HP[/TD]
[TD]0[/TD]
[TD]-23934[/TD]
[TD]-17326[/TD]
[TD]-10568[/TD]
[TD]-3662[/TD]
[TD]3387[/TD]
[TD]10573[/TD]
[TD]...[/TD]
[TD]26822[/TD]
[TD]30747[/TD]
[/TR]
[TR]
[TD]CF if CP > HP[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]CF per period[/TD]
[TD]0[/TD]
[TD]-26216[/TD]
[TD]-26610[/TD]
[TD]-27018[/TD]
[TD]-3662[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]-30388[/TD]
[TD]-30951[/TD]
[/TR]
</tbody>[/TABLE]


The equation I posted is being used in the "CF per period" row. The expected result is correct for periods 0-9, the problem is from period 10 and on. The "CF per period" for these periods should be 0, not the value in that period's "CF if CP < HP" row.
 
Upvote 0
I'm not getting the error you're getting...
How is B11 and E2:V2 populated, manually or by formula, I suspect leading and/or trailing spaces...


Book1
BCDEFGHIJKLMNOP
201234567891011
9
10Harvest PeriodCurrent02621626610270182744427887283483038830951
114Current=Harvest0239341732610568-36623387105732682230747
12Current>Harvest000000000
13
14CF per Period0262162661027018-36620000000
Sheet10
Cell Formulas
RangeFormula
E14=IF($B$11=E2,E11,IF($B$11))
 
Upvote 0
Seems to be working now. E2:V2 had error flags bc they were "numbers stored as text" and when I made the suggested correction from Excel everything was fixed.

Thanks for the help!
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,287
Members
452,631
Latest member
a_potato

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top