Look up employee rate based on date range

egrospeRP

New Member
Joined
Sep 5, 2018
Messages
15
Office Version
  1. 365
Platform
  1. Windows
Hello Excel Experts,
I have two tables in my excel sheet. First table is a labor detail containing date, employee ID, and employee name. This table contains transactional items when an employee enters their time.

The other table contains employee rate history. This table outlines employee ID, Employee name, hourly rate, effective date, and ineffective date.

What i'm trying to do is pull the employee hourly rate at the time the entry was made on the labor detail table. I'm using the following formula but it keeps returning result to 0.

I'm stuck and need help! :(

Labor Detail.xlsx
ABCD
1DateEmployee IDEmployeeLabor Rate (lookup)
24/1/2021100Employee 10
34/2/2021200Employee 20
44/3/2021200Employee 20
54/4/2021200Employee 20
64/5/2021200Employee 20
74/6/2021300Employee 30
84/7/2021300Employee 30
94/8/2021300Employee 30
104/9/2021300Employee 30
114/10/2021100Employee 10
124/11/2021300Employee 30
134/12/2021300Employee 30
144/13/2021200Employee 20
154/14/2021300Employee 30
164/15/2021100Employee 10
174/16/2021100Employee 10
184/17/2021100Employee 10
194/18/2021100Employee 10
204/19/2021100Employee 10
214/20/2021100Employee 10
224/21/2021100Employee 10
234/22/2021300Employee 30
244/23/2021300Employee 30
254/24/2021300Employee 30
264/25/2021300Employee 30
274/26/2021300Employee 30
284/27/2021300Employee 30
294/28/2021300Employee 30
304/29/2021300Employee 30
314/30/2021300Employee 30
325/1/2021100Employee 10
335/2/2021300Employee 30
345/3/2021300Employee 30
355/4/2021300Employee 30
365/5/2021300Employee 30
375/6/2021300Employee 30
385/7/2021300Employee 30
395/8/2021300Employee 30
405/9/2021100Employee 10
Labor Detail
Cell Formulas
RangeFormula
D2:D40D2=SUMIFS(Table4[Rate],Table4[Employee ID],[@[Employee ID]],Table4[Effective Date],">="&[@Date],Table4[Ineffective Date],"<="&[@Date])



Labor Detail.xlsx
ABCDE
1Employee IDEmployee Rate Effective DateIneffective Date
2100Employee 1$ 25.004/1/20219/30/2021
3200Employee 2$ 30.004/1/20216/30/2021
4200Employee 2$ 40.007/1/20219/30/2021
5300Employee 3$ 20.004/1/20215/30/2021
6300Employee 3$ 45.006/1/20216/25/2021
7300Employee 3$ 60.006/26/20219/30/2021
Rate History
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
using power query, bring each table into the PQE and then join them on the EE ID. Here are the Mcodes for each and then the join

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Employee ID", type text}, {"Employee", type text}})
in
    #"Changed Type"

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Effective Date", type date}, {"Ineffective Date", type date}, {" Rate ", type number}, {"Employee ID", type text}, {"Employee", type text}})
in
    #"Changed Type"

Power Query:
let
    Source = Table.NestedJoin(Table1, {"Employee ID"}, Table2, {"Employee ID"}, "Table2", JoinKind.LeftOuter),
    #"Expanded Table2" = Table.ExpandTableColumn(Source, "Table2", {" Rate ", "Effective Date", "Ineffective Date"}, {"Table2. Rate ", "Table2.Effective Date", "Table2.Ineffective Date"}),
    #"Added Custom" = Table.AddColumn(#"Expanded Table2", "Custom", each if[Date] >=[Table2.Effective Date] and [Date] <[Table2.Ineffective Date] then[#"Table2. Rate "] else null),
    #"Filtered Rows" = Table.SelectRows(#"Added Custom", each ([Custom] <> null)),
    #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Table2. Rate ", "Table2.Effective Date", "Table2.Ineffective Date"})
in
    #"Removed Columns"

Book3
FGHI
10DateEmployee IDEmployeeCustom
114/1/2021100Employee 125
124/2/2021200Employee 230
134/3/2021200Employee 230
144/4/2021200Employee 230
154/5/2021200Employee 230
164/6/2021300Employee 320
174/7/2021300Employee 320
184/8/2021300Employee 320
194/9/2021300Employee 320
204/10/2021100Employee 125
214/11/2021300Employee 320
224/12/2021300Employee 320
234/13/2021200Employee 230
244/14/2021300Employee 320
254/15/2021100Employee 125
264/16/2021100Employee 125
274/17/2021100Employee 125
284/18/2021100Employee 125
294/19/2021100Employee 125
304/20/2021100Employee 125
314/21/2021100Employee 125
324/22/2021300Employee 320
334/23/2021300Employee 320
344/24/2021300Employee 320
354/25/2021300Employee 320
364/26/2021300Employee 320
374/27/2021300Employee 320
384/28/2021300Employee 320
394/29/2021300Employee 320
404/30/2021300Employee 320
415/1/2021100Employee 125
425/2/2021300Employee 320
435/3/2021300Employee 320
445/4/2021300Employee 320
455/5/2021300Employee 320
465/6/2021300Employee 320
475/7/2021300Employee 320
485/8/2021300Employee 320
495/9/2021100Employee 125
Sheet1
 
Upvote 0
using power query, bring each table into the PQE and then join them on the EE ID. Here are the Mcodes for each and then the join

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Employee ID", type text}, {"Employee", type text}})
in
    #"Changed Type"

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Effective Date", type date}, {"Ineffective Date", type date}, {" Rate ", type number}, {"Employee ID", type text}, {"Employee", type text}})
in
    #"Changed Type"

Power Query:
let
    Source = Table.NestedJoin(Table1, {"Employee ID"}, Table2, {"Employee ID"}, "Table2", JoinKind.LeftOuter),
    #"Expanded Table2" = Table.ExpandTableColumn(Source, "Table2", {" Rate ", "Effective Date", "Ineffective Date"}, {"Table2. Rate ", "Table2.Effective Date", "Table2.Ineffective Date"}),
    #"Added Custom" = Table.AddColumn(#"Expanded Table2", "Custom", each if[Date] >=[Table2.Effective Date] and [Date] <[Table2.Ineffective Date] then[#"Table2. Rate "] else null),
    #"Filtered Rows" = Table.SelectRows(#"Added Custom", each ([Custom] <> null)),
    #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Table2. Rate ", "Table2.Effective Date", "Table2.Ineffective Date"})
in
    #"Removed Columns"

Book3
FGHI
10DateEmployee IDEmployeeCustom
114/1/2021100Employee 125
124/2/2021200Employee 230
134/3/2021200Employee 230
144/4/2021200Employee 230
154/5/2021200Employee 230
164/6/2021300Employee 320
174/7/2021300Employee 320
184/8/2021300Employee 320
194/9/2021300Employee 320
204/10/2021100Employee 125
214/11/2021300Employee 320
224/12/2021300Employee 320
234/13/2021200Employee 230
244/14/2021300Employee 320
254/15/2021100Employee 125
264/16/2021100Employee 125
274/17/2021100Employee 125
284/18/2021100Employee 125
294/19/2021100Employee 125
304/20/2021100Employee 125
314/21/2021100Employee 125
324/22/2021300Employee 320
334/23/2021300Employee 320
344/24/2021300Employee 320
354/25/2021300Employee 320
364/26/2021300Employee 320
374/27/2021300Employee 320
384/28/2021300Employee 320
394/29/2021300Employee 320
404/30/2021300Employee 320
415/1/2021100Employee 125
425/2/2021300Employee 320
435/3/2021300Employee 320
445/4/2021300Employee 320
455/5/2021300Employee 320
465/6/2021300Employee 320
475/7/2021300Employee 320
485/8/2021300Employee 320
495/9/2021100Employee 125
Sheet1
H
Hello Excel Experts,
I have two tables in my excel sheet. First table is a labor detail containing date, employee ID, and employee name. This table contains transactional items when an employee enters their time.

The other table contains employee rate history. This table outlines employee ID, Employee name, hourly rate, effective date, and ineffective date.

What i'm trying to do is pull the employee hourly rate at the time the entry was made on the labor detail table. I'm using the following formula but it keeps returning result to 0.

I'm stuck and need help! :(

Labor Detail.xlsx
ABCD
1DateEmployee IDEmployeeLabor Rate (lookup)
24/1/2021100Employee 10
34/2/2021200Employee 20
44/3/2021200Employee 20
54/4/2021200Employee 20
64/5/2021200Employee 20
74/6/2021300Employee 30
84/7/2021300Employee 30
94/8/2021300Employee 30
104/9/2021300Employee 30
114/10/2021100Employee 10
124/11/2021300Employee 30
134/12/2021300Employee 30
144/13/2021200Employee 20
154/14/2021300Employee 30
164/15/2021100Employee 10
174/16/2021100Employee 10
184/17/2021100Employee 10
194/18/2021100Employee 10
204/19/2021100Employee 10
214/20/2021100Employee 10
224/21/2021100Employee 10
234/22/2021300Employee 30
244/23/2021300Employee 30
254/24/2021300Employee 30
264/25/2021300Employee 30
274/26/2021300Employee 30
284/27/2021300Employee 30
294/28/2021300Employee 30
304/29/2021300Employee 30
314/30/2021300Employee 30
325/1/2021100Employee 10
335/2/2021300Employee 30
345/3/2021300Employee 30
355/4/2021300Employee 30
365/5/2021300Employee 30
375/6/2021300Employee 30
385/7/2021300Employee 30
395/8/2021300Employee 30
405/9/2021100Employee 10
Labor Detail
Cell Formulas
RangeFormula
D2:D40D2=SUMIFS(Table4[Rate],Table4[Employee ID],[@[Employee ID]],Table4[Effective Date],">="&[@Date],Table4[Ineffective Date],"<="&[@Date])



Labor Detail.xlsx
ABCDE
1Employee IDEmployee Rate Effective DateIneffective Date
2100Employee 1$ 25.004/1/20219/30/2021
3200Employee 2$ 30.004/1/20216/30/2021
4200Employee 2$ 40.007/1/20219/30/2021
5300Employee 3$ 20.004/1/20215/30/2021
6300Employee 3$ 45.006/1/20216/25/2021
7300Employee 3$ 60.006/26/20219/30/2021
Rate History

Hi Alansidman,
Thanks so much for your reply. I've used PQ before and continue to use it, but still not an expert with it and learning more every day. I'm going to try this solution (just haven't had the time yet), but I was wondering if there are any simpler solution other than PQ? Do you know if there's a simpler excel function/formula that would also accomplish this?

Reason being is this effort is going to be duplicated on a project by project basis, and I have to pass down this process to multiple folks who doesn't have the PQ knowledge.

I'd greatly appreciate it, thanks!
 
Upvote 0
There may other means to get what you want but not in my skill bank.
 
Upvote 0
Try

=SUMIFS(Table4[[ Rate ]],Table4[Employee ID],[@[Employee ID]],Table4[Effective Date],"<="&[@Date],Table4[Ineffective Date],">="&[@Date])

M.
 
Upvote 0
Solution

Forum statistics

Threads
1,214,599
Messages
6,120,447
Members
448,966
Latest member
DannyC96

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
Back
Top