If statement with date range

Mike820

New Member
Joined
Jul 24, 2019
Messages
21
Hi, I currently have data organized similar to below. I'm struggling to write a formula. I'm trying to do the following: if the oldest date tied to an ID is within the last 13 months then return "New" if the oldest date is older than 13 months then sum all the amounts for that relationship ID and if it's a positive number then return "In" if negative return "out".


IDDateAmountFormula column
112/1/20191000New
15/2/2019-2500New
211/5/20175000In
22/2019-3000In
33/2/2016-5000Out
 
Give this one a go, I've changed the date part of the formula so that it should always run for the correct period based on today's date (the bit in bold).

=IF(DATEDIF(MINIFS($B$2:$B$10,$A$2:$A$10,A2),EOMONTH(WORKDAY(TODAY(),1),-1),"M")<13,"New",IF(COUNTIFS($A$2:$A$10,A2,$D$2:$D$10,"<>closed")=0,"Closed",IF(SUMIFS($C$2:$C$10,$A$2:$A$10,A2)<0,"out","in")))

Effectively it always looks at the previous month based on TODAY(), but if TODAY() is the last weekday of the month then it will advance it to the current month.
 
Upvote 0

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Give this one a go, I've changed the date part of the formula so that it should always run for the correct period based on today's date (the bit in bold).

=IF(DATEDIF(MINIFS($B$2:$B$10,$A$2:$A$10,A2),EOMONTH(WORKDAY(TODAY(),1),-1),"M")<13,"New",IF(COUNTIFS($A$2:$A$10,A2,$D$2:$D$10,"<>closed")=0,"Closed",IF(SUMIFS($C$2:$C$10,$A$2:$A$10,A2)<0,"out","in")))

Effectively it always looks at the previous month based on TODAY(), but if TODAY() is the last weekday of the month then it will advance it to the current month.

Could you please explain this part of the formula and how it works? ",IF(COUNTIFS($A$2:$A$10,A2,$D$2:$D$10,"<>closed")=0,"Closed".

Thanks,
 
Upvote 0
It counts the number of rows with the same ID where the tag is anything other than closed.
If the result of that count is 0 then the result is 'closed'. Counts greater than 0 are passed to the next part to see if it is in or out.
 
Upvote 0

Forum statistics

Threads
1,214,812
Messages
6,121,704
Members
449,048
Latest member
81jamesacct

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