Determine location prior to comparing dates in Excel - excel-formula

I am trying to write a formula to compare a date against two dates but I need to determine the location of those two dates prior to comparison.
By way of example, I have dates in a table as below.
A B C D
1 FY QTR Start date End Date
2 2019 Q1 2/4/2018 5/5/2018
3 2019 Q2 5/6/2018 8/4/2018
4 2019 Q3 8/5/2018 11/3/2018
5 2019 Q4 11/4/2018 1/2/2019
I have the quarter I am working in cell B9. I want to determine if the date in cell H6 falls between start date and end date based on the quarter value in cell B9.

Test if H6 is >= Start date AND <= End Date
Assuming dates are entered as DateTime Serial Numbers (and formated as dates) use
=AND($H$6 >= VLOOKUP($B$9,$B$1:$D$5,2,0), $H$6 <= VLOOKUP($B$9,$B$1:$D$5,3,0))

Related

Excel count if date range is active in a certain month

I have 2 date, a start date and end date. I want to be able to count if these were active through a certain month.
Row 1: start date 20/11/2020, end date 03/02/2021.
Row 2: start date 03/01/2021, end date 15/03/2021
Row 2: start date 12/01/2021, end date 31/03/2021,
The columns I have are the months and based on the above data this is the expected result.
Nov 1
Dec 1
Jan 3
Feb 3
Mar 2
Is there a formula that I can use to count this through a range of 100's of rows?
A simpler method than what you posted in your comment.
Put your start/end dates in a Table and name it StartEndTbl
Create a column of months whereby
Each entry is the first day of the month
The column is formatted mmm-yyy
In the first cell (F2 in this case), enter the formula:
F2: =SUM((StartEndTbl[Start]<=EOMONTH(E2,0))*(StartEndTbl[End]>=E2))
and fill down as far as needed

Conditonal formatting after specific date

I have an Excelsheet with lot of dates.
I need to highlight the rows witch will be 6 months after given date but before march 1 2020.
Column A = Date
Column B= Date + 6 months
I would like column B to give me a color red or green if the column is before or after march 1 2020.
Start
Result

Compare dates yyyy with dd/mm/yyyy

In excel is it possible to compare a year yyyy (say 2016) with date dd/mm/yyyy (say 01/01/2015) and find out which is greater. My assumption would be that the date in yyyy format will always be the first day of the year.
So for example
2015 v 01/01/2014 would return true
2015 v 01/01/2015 would return false
2015 v 01/01/2016 would return false
I can code this in VBA but the user needs this in a cell in an excel spreadsheet.
One option would be to write the VBA code in a function in a code module, that returns the greater value.
Public Function CompareDates(date1 AS Date, date2 As Date) As Date
'Compare date1 and date2
'CompareDates = whichever date is greater
End Function
You can then simply add the formula =CompareDates(date1, date2) in the cell
Assuming A1 = 2015 and B1 = 01/01/2015 you can try:
A1=YEAR(B1)
Do you mean something like:
=DATE(A1,1,1)>B1
Assuming your Years are in Column A and Dates are in Column B.

How to find the last 8 quarters and their years from the current quarter and year or a given date

I am trying to find the last 7 quarters from the given quarter and year in MS Excel.
For eg.
if I have Q1 2016 then I should be able to find Q4 2015 in one cell and Q3 2015 in another cell and so on showing the last seven quarters. This should be dynamic i.e when the current quarter changes, the year should move also wherever required.
I have been able to find the last quarter number using the following formulas:
=CHOOSE(CEILING(MONTH(E4)/3,1),1,2,3,4)
and
=IF(F5-1=0,4,F5-1)
But I am not able keep the year dynamic.
If the current quarter is Q1 2015 then the quarters I need would be:
Q4 2015
Q3 2015
Q2 2015
Q1 2015
Q4 2014
Q3 2014
Q2 2014
Your question is not clear. But, with some date in E4, the following formula will return Qn YYYY. If you then fill right, it will return the preceding quarters. If your layout is different, you will need to adjust the formula accordingly.
EDIT Formula adjusted to be able fill right instead of down
F5: ="Q" & INT(MONTH(EDATE($E$4,-(COLUMNS($A:A)-1)*3))/3)+1 &" " & YEAR(EDATE($E$4,-(COLUMNS($A:A)-1)*3))
The formula subtracts a multiple of 3 months from the date in E4; and computes the quarter and year for that date. By using the ROWS function, that multiple is incremented each time you fill down one row.

How To automatically calculate Qtr Revenue given only two dates and Total Revenue

I could use some help writing an excel formula.
Case: Revenue is generated between 2 dates, Date A and Date B.
These dates could go into the next year and spread across quarters.
How can I split Revenue into Q1 Revenue, Q2 Revenue, Q3 Revenue, Q4 Revenue just based on my 2 dates and Total Revenue.
My thought was first identify which Qtr your dates fall into and then have an if statement that logically figures out the % and multiplies by the revenue.
Currently I'm using this formula to determine Qtr: =ROUNDUP(MONTH(DateA)/3,0).
Similarly for DateB.
Then, =if(DateAQtr=2, ((6/30/2013-DateA)/(DateB-DateA))*Revenue, 0)
There are clearly problems with this like, what happens if DateB(end Date) is in Q1 of the following year.
Denominator will always be Date B - Date A, giving you total days.
Numerator of Start Qtr is =(LastDayofQtr - Start).
Numerator of any quarters in the middle will be the full qtr length.
Numerator of End Qtr is =(EndDate - LastDayofPreviousQtr).
This is the logic. I'm trying to write into Excel formula to automate the process.
I made some named ranges to help see what is going on.
A2 = DateA, B2 = DateB, C2 = Revenue
A7 =DATE(YEAR(DateA),1,1) This is to establish the Q1 date for the DateA entered.
A8 =EDATE(A7,3) dragged down to cell A15 as in the picture. This returns the start of the next Quarter.
B7 =IF(AND(DateA>=A7,DateA<A8),A8-DateA,IF(AND(DateB>=A7,DateB<A8),DateB-A7,IF(AND(A7<DateB,A7>DateA),A8-A7))) This is checking how the dates compare to the Quarter start dates and returning the number of days our DateA and DateB date range contain for each Quarter.
C7 ="Q"&ROUNDUP(MONTH(A7)/3,0) dragged down to read the Qtr Start Date and return the corresponding Q#.
D7 =IF(B7=FALSE,"",C7&"-"&YEAR(A7)) returns the Q# and year when the days column is not false.
E7 =IF(D7="","",(Revenue/(DateB-DateA)*B7/Revenue)) This calculates the percentages of revenue that each quarter contains.
If you change the values of DateA or DateB everything still calculates properly. If you date range is larger than the two years displayed just drag the formulas down to expand the max range.
I hope this helps.

Resources