More efficient way to perform multi table lookup?

Tipsey

New Member
Joined
Oct 28, 2022
Messages
32
Office Version
  1. 365
Platform
  1. Windows
Hi I have a function performing the task I want it to, but I am curious if anyone can think of a better and more efficient way of accomplishing the task.

The idea is to type an employee # into a table, and then attempt to find out if that employee has a scheduled shift today.
Employee shifts are located in 6 separate tables, so I have made a formula like:

=XLOOKUP([@Number],Table1[Emp '#],Table1[Start],XLOOKUP([@Number],Table2[Emp '#],Table2[Start],XLOOKUP([@Number],Table3[Emp '#],Table3[Start],XLOOKUP([@Number],Table4[Emp '#],Table4[Start],XLOOKUP([@Number],Table5[Emp '#],Table5[Start],XLOOKUP([@Number],Table6[Emp '#],Table6[Start],"not in today"))))))

This does achieve the desired outcome, but as mentioned I would like to know if there is a better way.

Thanks
 
Hi I have a function performing the task I want it to, but I am curious if anyone can think of a better and more efficient way of accomplishing the task.

The idea is to type an employee # into a table, and then attempt to find out if that employee has a scheduled shift today.
Employee shifts are located in 6 separate tables, so I have made a formula like:

=XLOOKUP([@Number],Table1[Emp '#],Table1[Start],XLOOKUP([@Number],Table2[Emp '#],Table2[Start],XLOOKUP([@Number],Table3[Emp '#],Table3[Start],XLOOKUP([@Number],Table4[Emp '#],Table4[Start],XLOOKUP([@Number],Table5[Emp '#],Table5[Start],XLOOKUP([@Number],Table6[Emp '#],Table6[Start],"not in today"))))))

This does achieve the desired outcome, but as mentioned I would like to know if there is a better way.

Thanks
The first question is why are you storing employee shift data in so many different tables?
 
Upvote 0
If the Employee number is the 1st column in those table you could use something like
Excel Formula:
=VLOOKUP([@Number],VSTACK(table1,table2,table3),2,0)
 
Upvote 0
If the Employee number is the 1st column in those table you could use something like
Excel Formula:
=VLOOKUP([@Number],VSTACK(table1,table2,table3),2,0)
Unfortunately the employee number is in the 4th column and the start time is in the second column.

Excel Formula:
=HSTACK(VSTACK(DROP(TAKE(Table1,,4),,3),DROP(TAKE(Table2,,4),,3),DROP(TAKE(Table3,,4),,3),DROP(TAKE(Table4,,4),,3),DROP(TAKE(Table5,,4),,3),DROP(TAKE(Table6,,4),,3)),VSTACK(DROP(TAKE(Table1,,2),,1),DROP(TAKE(Table2,,2),,1),DROP(TAKE(Table3,,2),,1),DROP(TAKE(Table4,,2),,1),DROP(TAKE(Table5,,2),,1),DROP(TAKE(Table6,,2),,1)))

works, but is very ugly
 
Upvote 0
In that case you could use
Excel Formula:
=VLOOKUP([@Number],CHOOSECOLS(VSTACK(table1,table2,table3),4,2),2,0)
 
Upvote 0
Solution

Forum statistics

Threads
1,226,771
Messages
6,192,918
Members
453,766
Latest member
Gskier

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