Looking up Values froma t

singhb

New Member
Joined
Jun 29, 2015
Messages
5
Hello - i am struggling with writing a logic in the column "Key" of the "Fact" table below. A little background, the data in the "Dim" table pertains to employees and the "Title Eff Date" represents the date the employees' job responsibility changed. For example, employee with file number 1111 in the first table below was coded to job 40 on 01/01/2015. On 03/01/2015, his job duties were changed to job code 43 and were changed again to job code 45 on 10/02/2015.

The second table represents the punch in punch out data. For example, the first row in the Fact table states that employee 1111 punched into Department 60 on 05/30/2015.

I am trying to write a formula in the Key field of the Fact table that uses the Dim table as a lookup and assigns an appropriate key so both tables could be joined. The logic should be as follows. If employee 1111 in Fact table worked on 5/30/2015, the logic should look up all the records for the particular employee in the Dim table where the "Title Eff Date" is less than the Date on the Fact table, and then pick the key from the most recent record. For example, employee 1111 clocked on 05/30/2015 as shown in the Fact table. The second record in the Dim table indicates that he was coded to Dept 60, job 43 on 03/01/2015. If he clocked in on 05/30/2015 and the most recent change occurred on 03/01/2015, the the clock in must represent him working at dept 60, job code 43.

I have put in the right answers in in the Fact table in the first column. Any help is appreciated.

Dim
KeyFileDeptJob CodeTitle Eff Date
1111160401/1/2015
2111160433/1/2015
31111604510/2/2015
4222260542/1/2015
52222605610/1/2015

<tbody>
</tbody>


Fact
KeyFileDeptDate
21111605/30/2015
42222606/6/2015

<tbody>
</tbody>
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
I was able to figure it out. Below is the logic. It is an array function. Just so you know the first table goes in B2:F9 and the second table goes in H2:K5 in case you want to plug this into a spreadsheet and see the result.

=SUMIFS($B$4:$B$8,$F$4:$F$8,MAX(IF(I4=$C$4:$C$8,IF(K4>$F$4:$F$8,$F$4:$F$8,0))),$C$4:$C$8,I4)
 
Upvote 0

Forum statistics

Threads
1,214,386
Messages
6,119,220
Members
448,876
Latest member
Solitario

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