Finding if a time lies within time range, then returning values from the corresponding row

BBxcl

New Member
Joined
Sep 29, 2021
Messages
12
Office Version
  1. 365
Platform
  1. Windows
CE07EBA0-4F3D-44CE-ADD5-0E14E144701B.jpeg
Hi,

I have a big table of entries (called table1) that has Employee shift records. The table has Employee IDs, shift start times, shift end times and the income they have.

I want to create a spreadsheet that allows a user to enter an enquiry time during the day and it will return the highest income at that time and the corresponding employee ID.

The attached image is an example of some sample data.

I tried using the following formula to calculate the max income but get a #REF error:
=MAX(INDEX(Table1[Income],SUMPRODUCT(([@[Enquiry Time]]<Table1[End Time])*([@[Enquiry Time]]>Table1[Start Time])*(ROW(Table1[Income])))))

I have no idea what’s wrong and how I would calculate the employee ID of the highest earning employee as well.

Is anyone able to help with this?
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
77,493
Office Version
  1. 365
Platform
  1. Windows
How about
Excel Formula:
=INDEX(SORT(FILTER(Table1,(Table1[Start Time]<=F2)*(Table1[End Time]>=F2)),4,-1),1,{4,1})
but this will need to go in a normal range, not a table.
 

AlanY

Well-known Member
Joined
Oct 30, 2014
Messages
4,352
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
try this

Book1
ABCDEFGH
1IDStartEndIncomeTimeHighestID
223509:00:0010:00:0020009:30230236
323609:15:0010:00:00230
423810:20:0010:50:00300
523511:00:0011:30:0080
Sheet1
Cell Formulas
RangeFormula
G2G2=MAXIFS(D2:D5,B2:B5,"<="&F2,C2:C5,">="&F2)
H2H2=INDEX(A2:A5,MATCH(G2,D2:D5,0))
 
Solution

Forum statistics

Threads
1,175,494
Messages
5,897,738
Members
434,675
Latest member
AmitSatnalika

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
Top