Lookup Value based upon criteria

smalik

Board Regular
Joined
Oct 26, 2006
Messages
186
Office Version
  1. 365
Platform
  1. Windows
I regularly pull data from a system that has 14 fields for different roles. Some of these fields are empty and some have values. The value is the name of the employee (if that helps)

The fourteen fields are:
  • Field-1
  • Field-2
  • Field-3
  • etc.
I need to pull data for four roles only. The four roles are:
  • Sales
  • Service
  • Contact
  • Admin
The issue I am facing is that these four roles are never in the same location from office to office. For example, "Sales" employees may be listed in "Field-1" for Office-1 but for Office-2, "Sales" employees may be listed in "Field-8" and same is true to other three fields.

I thought defining these fields than writing a nested "if statement" with fourteen "hlookups" statements. However, this is very cumbersome and prone to errors. Is there a better way to write a formula if I define somewhere else which field is "Sales" vs. "Contact" vs. "Admin"?

I am sorry, I can only show a picture as my work computer does not allow me to download any add-ons.

Here is what I have:
The data from the source system is in "Columns G" through "Column T"
I need to pull the required fields in "Column B" through "Column E"
I created a "Table Definition" in a separate tab where I identify the required field

1669047806748.png


I hope I explained it well, but please feel free to ask for more clarity, if need be.

Thanks for your help in advance.
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
How about
Fluff.xlsm
ABCDEFGHIJKLMNOPQRST
1
2Sales LeadService LeadField-1Field-2Field-3Field-4Field-5Field-6Field-7Field-8Field-9Field-10Field-11Field-12Field-13Field-14
3adad
4bebe
5cc
6
7
8
9
10Field-1Sales Lead
11Field-2
12Field-3Service Lead
13Field-4
14Field-5
15Field-6
16Field-7
17Field-8
18Field-9
19Field-10
20Field-11
21Field-12
22Field-13
23Field-14
Main
Cell Formulas
RangeFormula
B3:B5,C3:C4B3=LET(f,FILTER($G$3:$T$12,$G$2:$T$2=FILTER($D$10:$D$23,$E$10:$E$23=B2)),FILTER(f,f<>""))
Dynamic array formulas.
 
Upvote 0
How about
Fluff.xlsm
ABCDEFGHIJKLMNOPQRST
1
2Sales LeadService LeadField-1Field-2Field-3Field-4Field-5Field-6Field-7Field-8Field-9Field-10Field-11Field-12Field-13Field-14
3adad
4bebe
5cc
6
7
8
9
10Field-1Sales Lead
11Field-2
12Field-3Service Lead
13Field-4
14Field-5
15Field-6
16Field-7
17Field-8
18Field-9
19Field-10
20Field-11
21Field-12
22Field-13
23Field-14
Main
Cell Formulas
RangeFormula
B3:B5,C3:C4B3=LET(f,FILTER($G$3:$T$12,$G$2:$T$2=FILTER($D$10:$D$23,$E$10:$E$23=B2)),FILTER(f,f<>""))
Dynamic array formulas.

Thank you... This formula works but I get into an issue:
1669054908750.png


Shame on me for not giving the full picture.
Each row is a record. The Sales Lead, Service Lead, etc., are all related to that records. Therefore, if there is no name in the filed, the desired result should be blank or whatever is in the source column.

For example, Sales-3 is for record 6 in the above example, so records 3,4,&5 should be blank in Column B. Then "Sales-3" should come for record 6.

In addition, the formula auto fills itself. When I try to copy the formula down from b3 down, I get the "#spill!" error. Any idea how to fix this?

1669055704377.png
 
Upvote 0
When I try to copy the formula down from b3 down
Don't, just put it in B3 & drag across.
To keep the blanks use
Excel Formula:
=LET(f,FILTER($G$3:$T$12,$G$2:$T$2=FILTER($D$10:$D$23,$E$10:$E$23=B2)),IF(f="","",f))
 
Upvote 0
Solution
Don't, just put it in B3 & drag across.
To keep the blanks use
Excel Formula:
=LET(f,FILTER($G$3:$T$12,$G$2:$T$2=FILTER($D$10:$D$23,$E$10:$E$23=B2)),IF(f="","",f))
Thank you.... this worked.

Sorry for the late reply.
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,279
Members
452,630
Latest member
OdubiYouth

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