How do I match a date from a list of dates in Excel? - excel

I need to compare two dates to see if they are equal from a list of dates in a column.
Eg. Sheet 1 Column A
Date 1
Date 2
Date 3
Date 4
Sheet 2 : Row F: Date 5
I want to see if date 5 is equal to any of the dates in column A and return true.
Please help me with this.

An alternative approach:
Assume Date1-Date4 are in A2:A5, and Date5 is in B2:
{=OR(B2=A2:A5)}
Note that you need to enter the formula as an array formula using Ctrl+Shift+Enter.

Related

FInd min Date in a date range with duplicate date

Using Excel and I'd like a formula that will return the earliest date from a row that contain duplicate date.
for example:
my row has 5 different dates, 1 duplicate and one blank cell
A B C D E F
09/01/2021 08/28/2021 09/08/2021 blank cell 09/01/2021 08/15/2021
I am using formula =MIN((A1:F1)
the return should be "8/28/2021" but I'm getting "1/1/1900"
can someone please help? that will be greatly appreciated
Try this:
=MIN(IFERROR(A1:F1*A1:F1/A1:F1,99999))
It will replace all the 0's with 99999 if it cannot be divided by itself (0).
(99999 is actually 10/13/2173 and was chosen at random as a date that will be later than the other dates on your list.)
You can do it with SMALL function:
SMALL function
My formula in column J is =SMALL(A1:G1;1)
Notice my date format is dd/mm/yyyy

Counting lowest values from multiple columns

I have a table and I need to count expiration for a year but I have two columns and I need to count the lowest value from them. What function would help with this. Here is a small Example
Name Expiration date Break date
Nr.1 31-Aug-2019 28-Feb-2023
Nr 2 18-Oct-2018
Nr 3 30-Sep-2018 21-Jun-2017
Nr. 4 1-Jan-2018
AS you can see there will be here:
2017 2018 2019 2020
1 2 1 0
You could use an extra "helper" column which takes the minimum between the expiration date and break date. (Accounting for the possibility of the Break date being empty)
Then your equation to find the totals for each year would just be a simple COUNTIF on that new column.
Slightly shorter version of a formula for the helper column:
=YEAR(IF(COUNT(B2:C2)=2,MIN(B2:C2),B2+C2))
with the difference that this will return a year (other than 1900) if there is a blank in the Expiration date column that is next to a populated cell in the Break date column.
For the actual counts I would choose a technique that has been deemed off topic for SO.
Solution with no helper column
Formula:
=SUMPRODUCT(--((($B:$B<$C:$C)+($C:$C=""))*($B:$B<>"")*(YEAR($B:$B)=E$1))+((($C:$C<$B:$B)+($B:$B=""))*($C:$C<>"")*(YEAR($C:$C)=E$1)))
Assumptions:
Data in columns A:C, with Expiration Date in B and Break Date in C
Year (2017,2018,2019,2010) in E1:H1
The formula can be dragged horizontally from E2 to H2.
Formula Logic (pseudo-code):
IF(OR(AND(OR(B<C,C=""),B<>"",YEAR(B)=X),AND(OR(C<B,B=""),C<>"",YEAR(C)=X))) THEN TRUE
Alternate Solution Using Table
Because the headers break the original formula, you'll need to make the column references more specific to where the data actually is. A table is the easiest way to do that.
=SUMPRODUCT(--(((Table1[Expiration Date]<Table1[Break Date])+(Table1[Break Date]=""))*(Table1[Expiration Date]<>"")*(YEAR(Table1[Expiration Date])=$E1))+(((Table1[Break Date]<Table1[Expiration Date])+(Table1[Expiration Date]=""))*(Table1[Break Date]<>"")*(YEAR(Table1[Break Date])=$E1)))
Tables don't play nice with formulas dragged horizontally, so I put the years in a column:
=SUM(IF(YEAR(IF($B$2:$B$5
Note: This is an array formula, you must paste it in the cell, then hit ctrl+shift+enter and then you can copy and paste it across your table.
The cell works if your data is in A1:C5 and you have the years you want to test across E1:H10. You could then paste the above formula in E2, and then paste accross your table.
The array formula does the following:
The first IF statement checks to see which value is lower, ColB or ColC.
The embedded IF statements then check to make sure the values are not 0. If they are 0 they return the other column, if they are not 0, they return its own non-0 value.
The YEAR function extracts the year from each date.
The last IF function preformed (but the first written in the function) tests the year against the cell above the sum. If the year matches, it returns 1, if false, 0
The SUM statement simply sums all the true values

How to do a running count of dates within a date range in excel?

I am trying to build a formula in excel, that will do a running count of dates within a specified date range for an item. For example: Item A has a Start Date of 7/15 and an End Date of 7/18. I need a formula that will "tally" or add "1" to a running count for 7/15, 7/16, 7/17, 7/18 in another column that has a comprehensive list of dates. How can I do this?
EXAMPLE ATTACHED AS LINK
Well... Some examples would be helpful, but it sounds like you're looking for countifs.
If we create two excel tables, one called Items with Start and End dates:
Title Start End
ItemA 7/15/2017 7/18/2017
ItemB 7/16/2017 7/20/2017
And one called Dates which counts the Items
Date Count
7/15/2017 1
7/16/2017 2
7/17/2017 2
7/18/2017 2
7/19/2017 1
7/20/2017 1
Then our formula in the Count column of Dates would be
=COUNTIFS(Items[Start],"<="&[#Date],Items[End],">="&[#Date])
In plain english, this is saying "Count all items in Table Items where the value in the Start column is less than or equal to the value in my Date column and the End column is greater than or equal to the value in my Date column. Note that these formulas are entirely in Excel Table format, which makes for more readable formulas. If we want A1 notation, we will assume that the Items table starts at A1, which would result in the following formula:
=COUNTIFS($B$2:$B$3,"<="&$E2,$C$2:$C$3,">="&$E2)

excel extract 6 digits from number, format as date and match with index match?

I have the following 2 worksheets.
Data:
Column B Column C Column D COLUMN E Column F
329115121601 3291 5555 =Date (MID(B8,9,2),MID (B8,7,2),MID (B8,5,2)) 50 <---- Week Number from date
I am trying to extract 6 digits from my number value in Columb B '151216' and want to put this into column E. The 6 digits represent a date which is 15th December 2016.
I am using mid to try and get the number and then date to try and format this as 15/12/2016 - however it's not working. Instead I get 15/12/16.
On my other sheet, 'Home' i am trying to look up the number from column B on sheet 'Data' using an index match (array formula) where the values in column C, D and E or F match.
Home:
Column H Column I Column J Column K
3291 5555 15/12/2016 or Week 50 {=IFERROR(INDEX(Data!$B:$B,MATCH(1,(Home!$H10=Data!$C:$C)*(Home!$I10=Data!$D:$D)*(IF(Home!$J10<55,Home!$J10,WEEKNUM(Home!$J10))=Data!$F:$F),0)),"No Po Found")}
The user should be able to enter either week number or a specific date and get a result.
For some reason, this formula works if the user enters a week number, but not if they enter a specific date. I'm not sure if this is a format issue with the date on sheet 'data' or with the index match formula. Please can someone show me where I am going wrong? Thanks
Excel defaults to 1916 when I input your formula, try adding "20"& to the start of the year parameter:
=Date("20"&MID(B8,9,2),MID(B8,7,2),MID(B8,5,2))
I think you are doing it well. Just need to format the date.
Right click on the cell that contains the date ( 15/12/16 ) then click on cell formatting option and choose the format you prefer.

To sum data for until a certain date

01-Mar 02-Mar 03-Mar
Actual 1 1 1
Allocation 3 0 2
Variance 2 -1 1
Assume the date today is 3rd March
How to sum the value of Actual until 2nd March only
use SUMIF:
=SUMIF($E$1:$G$1,"<2014-03-03",E2:G2) //range, criteria, sum range
if you want to sum values less than today, you can modify the formula as:
=SUMIF($E$1:$G$1,"<"&today()-1,E2:G2) //this will evaluate the criteria as dates till yesterday
Here's the sample output.
Update
If you're using a date value from cell to compare as criteria, make sure that it's a Date value otherwise it not give you desired output. See here in the formula bar:
The value in cell is "3-Mar" but is a date value as it shows in formula bar.
In case if it's a text value and you want to compare as date, use TEXT function to convert and then compare:
You can see here in below picture where I've a string value in cell K1 and in the next picture how i used TEXT function to convert and use it as a Date value:
Picture1
Picture2
HTH !

Resources