I have Start date + time and End date + time in table 1, then i have a range of dates and values in table 2. what i want is to find the highest value from table 2 that happened in the date range from table 1.
For example in table 1:
start date 12/30/2020 08:03 ; end date 12/31/2020 17:26
in table 2 is:
12/30/2020 08:00 1145
12/30/2020 09:00 2145
12/30/2020 10:00 3912
12/30/2020 08:00 1472
and so on. so in the row of table 1 i want to see the number 3912
Suppose both of your tables are structured reference table as shown below:
You can use either of the following formula to return the desired value:
=MAX((Table2[Date]>=Table1[#[Start Date]])*(Table2[Date]<=Table1[#[End Date]])*Table2[Value])
This one is using MAXIFS as suggested by Nicholas Hunter in the comment section:
=MAXIFS(Table2[Value],Table2[Date],">="&Table1[#[Start Date]],Table2[Date],"<="&Table1[#[End Date]])
Assuming table 1 = A1-B10 and table 2 is in D1-10,
try making another column (lets say F1-10) with the following: =IF(And(D1<B1,D1>A1),D1,0)
and in whatever cell you want the highest Date, put =Large(F1-10)
Make sure that the final cell has "Date" format, otherwise it will look like a weird number. if you want to look at the intermediary steps, do the same for F1-10.
Related
I have this file
Date | Time | Table | Checkin Time | Bill Number ..| .. |
7/1/2018 **18:03:48** **6** **18:03:48** **4332**
7/1/2018 18:11:23 **6** **18:03:48** **4332**
7/1/2018 18:23:10 **6** **18:03:48** **4332**
7/1/2018 19:24:11 8 19:24:11 4333
7/1/2018 19:56:17 8 19:24:11 4333
7/1/2018 20:31:11 *6 20:31:11 4332*
I need to calculate Checkin Time which is 1st time of table number and bill number.
For example See one customer checkin at 18:03:48 with table number 6
His Bill number is 4332 .
So for table number 6 and Bill number 4332 chekin time will be 1st time
which is 18:03:48.
So I applied the formula:
=IF(AND(E3=E2,C3=C2,A3=A2),D2,MIN(OFFSET(E3,0,-3,MATCH(0,(E3:E$35470=E3)*(C3:C$35470=C3)*(A3:A$35470=A3),0)-1,1)))
But the value changes at 6th row .
It's giving 20:31:11 as checkin time .
It should be 18:03:48 because the 6th row table number and bill number is same as 1st one.
So How do I make it possible, to calculate the checkin time as per 1st time who have same bill and table number , no matter which row .
Here is the excel file I have uploaded to Google drive.
Here is the screenshot.
Edit:- Formula by #jeeped work, But as the log is of 30 days
The data keeps repeating the other day too.
Can it be done by giving some unique date value ?
If you don't have the newer MINIFS and MAXIFS, use AGGREGATE to achieve the same result.
=AGGREGATE(15, 7, ((A$2:A$7)+(B$2:B$7))/((C$2:C$7=C2)*(E$2:E$7=E2)), 1)
Format the result any way you want; as date and time, time only, etc.
You can make use of an array formula combining INDEX+MATCH to return the earliest time value that matches your conditions first. In cell D2, enter the following:
=INDEX($B$2:$B$7,MATCH(1,($C$2:$C$7=C2)*($E$2:$E$7=E2),0))
When returning, be sure to press CONTROL+SHIFT+ENTER instead of just ENTER to make sure the formula calculates correctly.
#Jeeped's answer is spot on, here is an adjustment for the formula to work over multiple days that have the same table numbers and bill numbers:
=AGGREGATE(15, 7, ((A$2:A$13)+(B$2:B$13))/((C$2:C$13=C2)*(E$2:E$13=E2)*(A$2:A$13=A2)), 1)
All I did was add this extra conditional argument, that checks if the "Date" is the same:
*(A$2:A$13=A2)
I was hoping if somebody could give me a light to an Excel problem I'm trying to solve.
I have two tables. One called SENSOR and the other one CARD
1 - Table SENSOR has a date/time in one column and employee ID on the other
2 - Table CARD has a date/time in one column and employee ID on the other
The only exact match is the employee ID. The date/time from table SENSOR is not an exact match from table CARD (it is usually a couple of minutes plus or minus). What I need to do is to return on cell C1 the date/time column from table CARD that is the nearest time found in date/time column from SENSOR table.
TABLE SENSOR:
Column A: DATE/TIME
11/3/17 10:48
11/3/17 16:02
11/10/17 7:09
11/13/17 20:58
11/15/17 21:24
11/16/17 11:32
Column B: EMPLOYEE ID
7164
7165
7166
7163
7167
7163
TABLE CARD:
COLUMN I: DATE/TIME
11/3/17 16:05
11/10/17 7:10
11/13/17 21:04
11/15/17 21:30
11/16/17 11:40
11/3/17 10:45
COLUMN J: EMPLOYEE ID
7165
7166
7163
7167
7163
7164
Here is what I'm trying to do (It actually works in some of them, but in some others it just doesn't work and I can't understand why):
C1 =INDEX(I$2:I$285,MATCH(MIN(ABS(I$2:I$285-A16)),(J$2:J$285=B16)*ABS(I$2:I$285-A16),0))
Thank you guys
Since you mentioned TABLES I used TABLES and structured references. Makes things a bit easier, in the long run. But you should be able to translate to direct references, if you need to.
Here is the formula:
=LOOKUP(2,1/(AGGREGATE(15,6,(ABS(([#[EMPLOYEE ID]]=CARD[EMPLOYEE ID])*
CARD[DATE/TIME]-[#[DATE/TIME]])),1)=ABS(([#[EMPLOYEE ID]]=CARD[EMPLOYEE ID])*
CARD[DATE/TIME]-[#[DATE/TIME]])),CARD[DATE/TIME])
compare employee ID in Sensor with employee ID in card
return an array of the matching date times or zero's (if not match)
subtract from that the date/time in the current row and return the ABS value
using LOOKUP, return the last time that is in the same position as the minimum (ABS) difference.
the AGGREGATE function is used to avoid dealing with error values. It also allows avoiding using ctrl+shift+enter for array formula.
Case 1
I have a set of data which i need to determine if the cell is in Business Hours or Not.
8 - 18 (08:00 - 18:00) Business Hours (BH)
outside the timeframe is Non Business Hours (NBH)
Given Cell value for example is = "7" (which is NBH)
here is the formula i created =if(AND(C2>=8,C2<=18 ),"BH","NBH")
Case 2
I have a set of data for days in a week, i need to determine if the cell is in Weekdays or Weekends.
I have this formula = =if(OR(I2="Saturday", I2="Sunday"), "NBH", "BH")
note : i used the same variable name NBH - Weekends , BH - Weekdays
What I really need to do is to combine those two cases into 1 formula.
I need to output these scenarios correctly, listing below :
Time is 08:00, date is Saturday/Sunday = Combined formula of case 1 and 2 should output "NBH"
Time is 07:00, date is Monday-Friday = Combined formula of case 1 and 2 should output "NBH"
Time is 12:00, date is Monday-Friday = Combined formula of case 1 and 2 should output "BH"
Formulas can be seen in column BH/NBH WEEKDAYS and BH/NBH Weekends, you can browse attached file thanks much!
Click to access the file
If you want to calculate it directly on the initital values:
=IF(OR(H2="Saturday", H2="Sunday", B2>18, B2<8), "NBH", "BH")
p.s. Alternatively you can combine the already calculated columns, if you intend to keep these columns:
=IF(AND((E2="BH"), (D2="BH")), "BH", "NBH")
I have this set of data:
A B
1 1/1/15 6:05am
2 1/1/15 10:00am
3 1/2/15 6:10am
4 1/2/15 11:58am
Data in column A is a valid Excel date field and data in column B is valid Excel time field.
What I am trying to get is the time of the first call per day. Example:
1/1/15 6:05am
1/2/15 6:10am
I have tried PivotTables with sort and groups but that did not work. Any ideas/suggestions are most welcome.
In C1 copied down to suit please try:
=MIN(IF(A:A=A1,B:B))
with Ctrl+Shift+Enter.
However a PivotTable could well be a suitable alternative:
I am trying to lookup a value in one sheet based on three criteria. The lookup formula resides in the Operational Data sheet which contains data from the machine which reports every ten minutes and has a structure similar to the table below (simplified for the sake of simplification)
DateTime Status => ShouldBe
01/12/2010 01:00:01 ? 16
01/12/2010 02:00:01 ? 16
01/12/2010 03:00:01 ? 16
01/12/2010 04:00:01 ? 0
01/12/2010 05:00:01 ? 0
01/12/2010 06:00:01 ? 0
...
08/12/2010 07:00:01 ? 204
The Status column should reference the Status Data sheet which contains data of the machine's operating status. This only reports change in the machine's status, ie is not periodic. The Status Data sheet has a structure similar to that below (again simplified for the sake of simplification)
Error Code Start Time End Time
16 01/12/2010 00:00:01 01/12/2010 03:08:56
0 01/12/2010 03:08:56 06/12/2010 12:01:21
204 06/12/2010 12:01:21 15/12/2010 01:14:01
0 15/12/2010 01:14:01 20/12/2010 09:12:42
Any ideas?
-- edit
From a quick web search there appers to be two approaches to lookup with mulitple criteria. This first being to add another column of concatenated valeus and using VLOOKUP on a concatenated string. This is not appropriate because I am trying to search based on < and > (less/greater then) on the date columns.
I couldn't figure out how to use MATCH for this because the third argument defines weather the LOOKUP is a a greater/less than and I can't combine the two.
For example:
'Operation Data'!DateTime > 'Status Data'!StartTime and 'Operation Data'!DateTime < 'Status Data'!EndTime
If on sheet 'Status' Error codes are in Column A and Start time in Column B
on sheet 'Operational Data' DateTime is in column A
Formula is, for a cell in row 2
INDEX('Status'!$A:$A,MATCH(A2,'Status'!$B:$B,1))
Assumes data in sheet 'Status' is sorted ascending on Start Time
I think you have a couple of options:
1) You add a new column which is a concatenation of your 3 lookup criteria and do your lookup based on this.
2) The second option is an INDEX MATCH array formula, there is an example on here: http://www.ozgrid.com/forum/showthread.php?t=46692&page=1