Excel (IF) conditions with dates and changing status based on future dates - excel

I have a question on excel, trying to use the below formula, if you can insert it in cell B4 and it will be referencing dates from column C. When testing this for date range 01-May-2022 till 30-Aug-2022, it displays a few FALSES, I am trying to fill these statuses without generating any issues with code, so it works flawlessly. At this stage the more I try to tweak it, the more it breaks.
The status I am requiring is:
If Today() is 31+ days before Column C date range, then "Not Due"
If Today() is anywhere between 1 and 30 before column C date range then "Due Soon"
If Today() = column C date, then "Due"
If Today() is greater than column C date then "Overdue"
Can anyone please suggest a fix for date ranges 01-May-2022 till 30-Aug-2022, appreciate it! False is observed for 26 June 2022, 26 July 2022, 27 July 2022, and 08 April 2023.
There is another False I have observed which appeared sometime around June 2023 for this formula, not sure if it is an issue with Excel?
Thank you.
Formula
=IF($C4="Not Required","Not Required",IF(ISNUMBER(VALUE(LEFT($C4,1))),IF(TODAY()>$C4,"Overdue",IF(AND(TODAY()<$C4,TODAY()>($C4-30)),"Due Soon",IF(TODAY()<($C4-31),"Not Due")))))

Something like this should work for you:
=IF($C4="Not Required",$C4,IF(ISNUMBER($C4),CHOOSE(MATCH($C4-TODAY(),{-99999,0,1,31}),"Overdue","Due","Due Soon","Not Due"),"Not Due"))

Related

Excel | nested IF statements using dates

I'm trying to calculate the number of months in a given time range that fall within 2019.
My data looks like this:
I changed the format of my Start Date and End Date columns to "date". The "Duration in months" and output column have number formatting.
I approached it as follows:
If Start Date (year) < 2019 AND End date (year) = 2019, take the number of months between 1-1-2019 and the end date.
If start Date (year) < 2019 AND End date (year) > 2019, the number of months in 2019 = 12
If start Date (year) = 2019 AND End date (year) = 2019, take the number of months between Start Date and End date.
If start Date (year) = 2019 AND End date (year) > 2019, take the number of months between Start Date and 1-1-2020.
For all other cases, the number of months = 0.
I then followed the instructions from this website for nested IF functions.
I came up with the following formula: (Edit: changed last datedif to 2020 instead of 2019)
=IF(AND(YEAR(A3)<2019;YEAR(C3)=2019);DATEDIF(DATE(2019;1;1);C3;"m");IF(AND(YEAR(A3)<2019;YEAR(C3)>2019);12;IF(AND(YEAR(A3)=2019;YEAR(C3)=2019);DATEDIF(A3;C3;"m");IF(AND(YEAR(A3)=2019;YEAR(C3)>2019); DATEDIF(A3;DATE(2020;1;1);m);0))))
For the first 4 rows, it correctly returns 12.
For row 7 and 8, however, it returns #NAME? .
No matter what I try, I can't seem to get it to work. Any ideas on how I can solve this?
Much appreciated!
Amy
For the entire formula you have been consistent, apart from the last IF statement, where you went wrong within your DATEDIF( statement:
DATEDIF(A3;DATE(2019;1;1);m);0)
First of all you forgot to put m in quotes: "m"
Secondly you accidentally swapped the Date and Cell references, so it would have resolved #NUM. The full correct formula should be:
=IF(AND(YEAR(A7)<2019;YEAR(C7)=2019);DATEDIF(DATE(2019;1;1);C7;"m");IF(AND(YEAR(A7)<2019;YEAR(C7)>2019);12;IF(AND(YEAR(A7)=2019;YEAR(C7)=2019);DATEDIF(A7;C7;"m");IF(AND(YEAR(A7)=2019;YEAR(C7)>2019);DATEDIF(DATE(2019;1;1);A7;"m");0))))
Which will give you the result 4.
Alternatively, the following will give you the amount of full months between two dates. This works with your sample where your dates start on the first day of a month:
Formula in D2:
=SUMPRODUCT((DATE(2019,ROW($1:$12),1)>=A2)*(DATE(2019,ROW($1:$12),1)<=C2))
You've missed the quotes round the final "m" - try
=IF(AND(YEAR(A3)<2019;YEAR(C3)=2019);DATEDIF(DATE(2019;1;1);C3;"m");IF(AND(YEAR(A3)<2019;YEAR(C3)>2019);12;IF(AND(YEAR(A3)=2019;YEAR(C3)=2019);DATEDIF(A3;C3;"m");IF(AND(YEAR(A3)=2019;YEAR(C3)>2019); DATEDIF(A3;DATE(2019;1;1);"m");0))))

How to convert a month number (i.e. "12") into month name in Excel?

I've got data in a spreadsheet that's formatted YYYYMM and I need to convert it to Month Year format (i.e. 201406 -> June 2014)
I'm using RIGHT() and LEFT() to pull the corresponding bits from the initial data cells, but I can't figure out how to turn the month number into a month name (i.e. 06 -> June, 01 -> January, etc.)
I've tried TEXT(RIGHT(B2,2),"mmmm") which only returns January regardless of the number inputted.
Ideally this should be easy, so, any thoughts? Thanks.
You can use DATE([Year],[Month],[Day]) passing any values for year and day. Just note that this will make the actual value of the cell different to 12 though.
Excel will be reading 12 as a date which will be 12 days after 00/01/1900 (this is 0 as a date) returning 12/01/1900 which is in January.
TEXT(DATE(1,B2,1),"mmmm")
To make 201406 -> June 2014, The Date() formula would do pretty good job indeed. This is the whole formula that would make the transition:
=TEXT(DATE(LEFT(A1,4),RIGHT(A1,2),1),"MMMM YYYY")
Or something hardcoded as this can work:
=CHOOSE(B1,"January","February","March","April","May","June","July")
Another way is to add "01" to the end of your number so you can format it to look like a date, and then return the month from it.
=Text($A$1 & "01","####-##-##") will return 2014-06-01.
=TEXT("2014-06-01","mmmm yyyy") will return June 2014.
So....
=TEXT(TEXT($A$1 & "01","####-##-##"),"mmmm yyyy") returns June 2014.

How to auto populate the next week in excel

I am making an on-call schedule in excel and I can't for the life of me find an easy way to populate the dates. For example, someone is on call from Monday to Sunday, January 2nd - January 8th. Then the next person is on call from January 9th - January 15th. I am trying to figure out a way or formula to just "Drag" down the column and it input the next 7 day range. I have tried input the start date and end date in a separate cell, then using concatenate but it returns the date number in excel (forgot what its called). I also tried =(A1&" - "&B1) but that returns the same 5 digit number.
Any help or pointers are greatly appreciated!
Previous date + 7
If you have genuine dates, say in cells A1 "start date" and B1 "end date":
Jan 2 Jan 8
Then the next line will be
=A1+7 =B1+7
Verify Dates
To see, if the "Dates" you entered are realy dates excel can work with like that, apply "General formatting" to the A1 and B1 cells. If the resulting value is an Interer or a Decimal number, you are golden. If the resulting value did not change, you have a text and you need to apply different approach.
Perhaps you are looking for this:
=TEXT(A1,"d-mmm")&" - "&TEXT(B1,"d-mmm")
The formatting specification can be copied from the formatted cell properties.

Excel - Convert a range of text to dates in a formula

The two columns in my data referred to in this formula are "Carrier" and the other column is "OriginalEffectiveDate". The second column consist of a range of dates over a two year span. I need to show a like count of carriers for both years.
So if the range of dates is Jan 1, 2014 to July 12, 2015 then I only want to count the carriers in 2014 up to July 12, 2014. So in other words; if I counted all of 2014 compared to just a portion of 2015 then my numbers would be off.
The results would be something like:
2014 = 343 (Jan 1 - July 12, 2014)
2015 = 375 (Jan 1 - July 12, 2015)
When I set the file up originally the data I was using was static and the dates were numeric fields. When I took the same file and made the connection directly to the database the dates are now coming in as text and I cant get the same formula to work.
Thanks in advance for your help.
=COUNTIFS(tbl_Group[Carrier],A5,tbl_Group[OriginalEffectiveDate],"<="&EDATE(MAX(tbl_Group[OriginalEffectiveDate]),-12))
Photo:
Can you add a calculated column to your table?
If so, try this: add column called CalculatedDate with formula =DATEVALUE([#OriginalEffectiveDate])
Your CountIfS formula becomes
=COUNTIFS(tbl_Group[Carrier],A10,tbl_Group[CalculatedDate],"<="&EDATE(MAX(tbl_Group[CalculatedDate]),-12))
Note: DATEVALUE will make assumptions about potentially ambiguous dates, in my case yyyy-mm-dd based on my regional settings.
The reason COUNTIFS can't work without a calculated column is that the criteria_range parameters must be a direct range, and tbl_Group[OriginalEffectiveDate] are strings, not dates.
An alternative formula that doesn't require a calculated column is
=SUMPRODUCT(
(tbl_Group[Carrier]=A12) *
(DATEVALUE(tbl_Group[OriginalEffectiveDate]) <=
MAX(EDATE(DATEVALUE(tbl_Group[OriginalEffectiveDate]),-12))
)
)

Check if any date within a range is within 1 month of todays date

I've got a column full of dates. How can I check that column to find which date is within a month of todays date, and then return it?
If there is no date within a month, just return blank
Lets say my dates are:
01-Jan-12
01-Apr-12
01-Jul-12
01-Oct-12
01-Jan-13
The code im using is below. A:A is the range of the dates above
=MIN(IF(A:A>TODAY(),A:A))
The issue im having is that if I use the above, it returns 01/01/12 and not 01/01/13. Also, if I change the dates so the next date is December 1st 2012, it still returns 01/01/12
So you really just want the earliest date if that's within a month? If so perhaps try
=IF(MIN(A:A)-TODAY()<=30,MIN(A:A),"")
Assumes dates in column A
If you have past and future dates try this formula
=IFERROR(SMALL(IF(A2:A100>=TODAY(),IF(A2:A100<=TODAY()+30,A2:A100)),1),"")
confirmed with CTRL+SHIFT+ENTER
or for exactly 1 month (rather than 30 days) try using EDATE, i.e.
=IFERROR(SMALL(IF(A2:A100>=TODAY(),IF(A2:A100<=EDATE(TODAY(),1),A2:A100)),1),"")

Resources