Help with IF AND formula again

BrutalLogiC

Active Member
Joined
Feb 26, 2006
Messages
267
Office Version
  1. 2016
Platform
  1. Windows
I'm trying to write a formula to work out future potential monthly revenue based on contract start dates and their associated payment terms and value... hopefully someone can assist

The input cells would be:
Column V from cell V12 is the contract monthly value
Column W from cell W12 is the contract start date which is always start of month
Column X is the end date of the contract which is always end of month
Column AA is the first month the contract will be invoiced... typically either "1" or "3"
Column AB is the number of months which will be invoiced every time an invoice is raised (the billing frequency)... typically either "1" or "3" or "12"
Column AC is the month the first invoice will actually be paid... typically either "2" or "3"
Row 11 is the forecast months... first month is "May-19" in cell AE11

example 1:
V12 = $1,000 (the monthly contract value)
W12 = 01 May 2019 (the contract start date)
AA12 = 1 (i.e. the first invoice will be raised in the first month of the contract which would be May in this example)
AB12 = 3 (i.e. each invoice raised will be for 3 months' value, AB12*V12)
AC12 = 3 (i.e. each invoice raised will be paid in month 3... with month 1 being the month the invoice is raised.. so in this example it would be July19)

So in the forecast I would expect to see
May = 0 (cell AE12)
June = 0 (cell AF12)
July = $3000
Aug = 0
Sept = 0
Oct = $3000
Nov = 0
Dec = 0
Jan = $3000

example 2:
V12 = $1,000 (the monthly contract value)
W12 = May 2019 (the contract start date)
AA12 = 1 (i.e. the first invoice will be raised in the first month of the contract which would be May in this example)
AB12 = 1 (i.e. each invoice raised will be for 1 month's value, AB12*V12)
AC12 = 2 (i.e. the first invoice will be paid in month 2 and then every month thereafter)

So in the forecast I would expect to see
May = 0
June = $1000
July = $1000
Aug = $1000
Sept = $1000
Oct = $1000

example 3:
V12 = $1,000 (the monthly contract value)
W12 = 01 May 2019 (the contract start date)
AA12 = 3 (i.e. the first invoice will be raised in the third month of the contract which would be July)
AB12 = 3 (i.e. each invoice raised will be for 3 months' value, AB12*V12)
AC12 = 4 (i.e. the first invoice will be paid in month 4.. then 7...10...etc.)

So in the forecast I would expect to see
May = 0
June = 0
July = 0
Aug = $3000
Sept = 0
Oct = 0
Nov = 0
Dec = $3000
Jan = 0

I haven't factored the end date into any of these examples but if the current month was post the contract end date then there would be no further invoices raised or income received.
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
try this


Book1
VWXAAABACADAEAFAGAHAIAJAKALAMAN
11May-19Jun-19Jul-19Aug-19Sep-19Oct-19Nov-19Dec-19Jan-20Feb-20
12100001/05/201931/01/20201330030000030000030000
13100001/05/20191120100010001000100010001000100010001000
14100001/05/20193340003000003000003000
15100001/06/201931/01/20201320030000030000030000
Sheet3
Cell Formulas
RangeFormula
AE12=IF(AND(AE$11>=EDATE($W12,$AC12-1),MOD(MONTH(AE$11)-MONTH(EDATE($W12,$AC12-1)),$AB12)=0),$V12*$AB12,0)
 
Upvote 0
Thanks again Alan! I can't get that to work, if the end date in your example is 31/01/20 and I drag the cells further across there is still income appearing, in Apr-20, July-20 etc, is it the same for you?

It should be
May = 0
June = 0
July-19 = 3,000
Aug = 0
Sept =0
Oct = 3,000
Nov = 0
Dec = 0
Jan-20 = 3,000
then 0 for every month thereafter as contract ended in Jan-20

I just realised that if the end date is 29-02-20 (contract duration 10 months) and 3 months are billed at a time then final month (Feb 20) will need to be a single month.. that sounds a bit complex?
 
Upvote 0
Well, I haven’t make use of the contract end date in the formula. You need to add an additional condition in the AND() function to cover that.
 
Upvote 0
modified for the last month of the contract to invoice the outstanding


Book1
VWXAAABACAEAFAGAHAIAJAKALAMANAOAPAQ
11May-19Jun-19Jul-19Aug-19Sep-19Oct-19Nov-19Dec-19Jan-20Feb-20Mar-20Apr-20May-20
12100001/05/201931/03/20201330030000030000030000200000
13100001/05/201931/03/20201120100010001000100010001000100010001000200000
14100001/05/201931/03/20203340003000003000003000200000
15100001/07/201930/04/20201340000030000030000040000
16100001/07/201930/04/20201330000300000300000300010000
17100001/08/201930/04/20201340000003000003000030000
Sheet2
Cell Formulas
RangeFormula
AE12=IF(AE$11<$X12,IF(MONTH(EDATE(AE$11,0))=MONTH(EDATE($X12,0)), MONTH($X12-$W12)*$V12-SUM(AD12:$AE12), IF(AND(AE$11>=EDATE($W12,$AC12-1),MOD(MONTH(AE$11)- MONTH(EDATE($W12,$AC12-1)),$AB12)=0),$V12*$AB12,0)),0)
 
Upvote 0
Hi Alan. Thanks again for your reply. I'm trying to use the formula with
W12 start date 01-06-19
X12 end date 01-06-22
row 11 starting at column AE with Mar-19 (instead of May-19)

but I just can't seem to get it to work, as the wrong value 12,000 appears against June19 (AF12) then -15,000 against June2020 (AT12)

I can't quite figure out what's going on.. help please
 
Upvote 0
think i might finally cracked it, the problem was i assumed the contract end the end of the month and that been fixed now.


Book1
VWXAAABACAEAFAGAHAIAJAKALAMANAOAPAQARASATBP
11May-19Jun-19Jul-19Aug-19Sep-19Oct-19Nov-19Dec-19Jan-20Feb-20Mar-20Apr-20May-20Jun-20Jul-20Aug-20Jun-22
12100001/05/201931/03/2020133 300030003000
13100001/05/201931/03/20201121000100010001000100010001000100010002000
14100001/05/201931/03/2020334300030003000
15100001/07/201931/07/20201343000300030004000
16100001/07/201930/04/2020133300030003000
17100001/08/201930/04/202013430003000
18100001/06/201930/06/202213430003000300030004000
Sheet2
Cell Formulas
RangeFormula
AE12=IF(AND(AE$11>=EDATE($W20,$AC20-1),AE$11<=$X20),IF(MOD(MONTH($W12)+$AC12-1,$AB12)= MOD(MONTH(AE$11),$AB12),IF(AND($X12>=AE$11,$X12<=EOMONTH(AE$11,0)), IF(AND($X12>=AE$11,$X12<=EOMONTH(AE$11,0)),(DATEDIF($W12,$X12,"m")+1)* $V12-SUM(AD12:$AE12),0),IF(AND(AE$11>=EDATE($W20,$AC20-1),AE$11<=$X20, MOD(MONTH($W12)+$AC12-1,$AB12)=MOD(MONTH(AE$11),$AB12)),$V12*$AB12,"")),""),"")
 
Upvote 0
Cheers but what are the references to row 20 doing? I'm not sure how to adjust on my own data that goes from rows 12 to 82.
 
Upvote 0
typo, it's the working rows.

Code:
=IF(AND(AE$11>=EDATE($W12,$AC12-1),AE$11<=$X12),IF(MOD(MONTH($W12)+$AC12-1,$AB12)=
MOD(MONTH(AE$11),$AB12),IF(AND($X12>=AE$11,$X12<=EOMONTH(AE$11,0)),
IF(AND($X12>=AE$11,$X12<=EOMONTH(AE$11,0)),(DATEDIF($W12,$X12,"m")+1)*
$V12-SUM(AD12:$AE12),0),IF(AND(AE$11>=EDATE($W12,$AC12-1),AE$11<=$X12,
MOD(MONTH($W12)+$AC12-1,$AB12)=MOD(MONTH(AE$11),$AB12)),$V12*$AB12,"")),""),"")
 
Upvote 0

Forum statistics

Threads
1,215,545
Messages
6,125,450
Members
449,227
Latest member
Gina V

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