Return Multiple Column Headers Based On Specific Row Content THEN Search Based On Returned Values

Dancing Fish

New Member
Joined
Nov 1, 2021
Messages
6
Office Version
  1. 365
Platform
  1. Windows
I'm trying to translate matrix tables into a search in order to simplify what is on the tables. These are tracking what users are assigned to specific job codes, then what job codes are assigned to which training. The matrix tables are a couple hundred rows.

My first challenge is to get a list of what job codes a user might have and is laid out like below. A user can have multiple job codes and each applicable one is indicated with an "x".

Table 1: User's Job Codes
Job Code 1Job Code 2Job Code 3Job Code 4
User 1xxx
User 2x
User 3xx

If I wanted to search by a specific user ex: User 1, how would I get a list of all job codes applicable to them?

Output desired:
User Name entered hereReturned Job Codes
(User 1)Job Code 1
Job Code 2
Job Code 3



My second challenge is then to search these returned job codes for their assigned training courses. Another matrix table contains this relationship in a similar format. I can invert the table if needed.

Table 2: Training Courses' Job Codes
Job Code 1Job Code 2Job Code 3Job Code 4
Training Course 1xx
Training Course 2x
Training Course 3xx

Looking for the same type of output, just a list of all the training courses for the user.

Output desired:
User Name entered here (User 1)Returned Job CodesReturned Training Courses
Job Code 1Training Course 1
Job Code 2Training Course 3
Job Code 3
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
How about this?

Book1
ABCDEFGHI
1Job CodesTraining Courses
2Job Code 1Job Code 2Job Code 3Job Code 4User 1Job Code 1Training Course 1
3User 1xxxJob Code 2Training Course 3
4User 2xJob Code 3
5User 3xx
6
7
8
9Job Code 1Job Code 2Job Code 3Job Code 4
10Training Course 1xx
11Training Course 2x
12Training Course 3xx
Sheet3
Cell Formulas
RangeFormula
H2:H4H2=LET(t,TRANSPOSE(IFERROR(INDEX(B2:E2,(COLUMN(B2:E2)-1)/(INDEX(B3:E5,XMATCH(G2,A3:A5,0),0)="x")),"")),FILTER(t,t<>""))
I2:I3I2=INDEX(A10:A12,UNIQUE(FILTERXML("<a><b>" & TEXTJOIN("</b><b>",1,IFERROR(ROW(A10:A12)/(INDEX(B10:E12,SEQUENCE(ROWS(A10:A12)),XMATCH(TRANSPOSE(FILTERXML("<a><b>" & SUBSTITUTE(H2,", ","</b><b>") & "</b></a>","//b")),B9:E9,0))="x")-ROW(A10)+1,"")) & "</b></a>","//b")),0)
Dynamic array formulas.
 
Upvote 0
Another option
+Fluff 1.xlsm
ABCDEFGHIJ
1Job Code 1Job Code 2Job Code 3Job Code 4
2User 1xxxUser 1Job Code 1Training Course 1
3User 2xJob Code 2Training Course 3
4User 3xxJob Code 3
5
6
7
8
9
10
11
12Job Code 1Job Code 2Job Code 3Job Code 4
13Training Course 1xx
14Training Course 2x
15Training Course 3xx
Main
Cell Formulas
RangeFormula
I2:I4I2=TRANSPOSE(FILTER(B1:E1,FILTER(B2:E4,A2:A4=H2,"")="x",""))
J2:J3J2=IFERROR(UNIQUE(FILTERXML("<k><m>"&TEXTJOIN("</m><m>",,IF(FILTER(B13:E15,ISNUMBER(MATCH(B12:E12,I2#,0)),"")="x",A13:A15,""))&"</m></k>","//m")),"")
Dynamic array formulas.
 
Upvote 0
Solution
You could also do this using Power Query.

Name this table 'User'
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Column1 = Source{0}[Column1]
in
    Column1

Name this table 'Jobs'
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
    UP = Table.UnpivotOtherColumns(Source, {"Column1"}, "Attribute", "Value"),
    SR = Table.SelectRows(UP, each ([Column1] = User)),
    ROC = Table.SelectColumns(SR,{"Attribute"})
in
    ROC

Name this table 'Train'
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table3"]}[Content],
    UP = Table.UnpivotOtherColumns(Source, {"Column1"}, "Attribute", "Value"),
    SR = List.Distinct(Table.SelectRows(UP, each (List.Contains(Jobs[Attribute],[Attribute])))[Column1])
in
    SR

Table 1 will be the range I3 in the example below. Table 2 will be the first table with the job codes, and Table 3 will be the table with the training courses.

Book1
ABCDEFGHIJK
2Column1Job Code 1Job Code 2Job Code 3Job Code 4UserJob CodesTraining
3User 1xxxUser 1Job Code 1Training Course 1
4User 2xJob Code 2Training Course 3
5User 3xxJob Code 3
6
7
8
9Column1Job Code 1Job Code 2Job Code 3Job Code 4
10Training Course 1xx
11Training Course 2x
12Training Course 3xx
Sheet4
 
Upvote 0
Another option
+Fluff 1.xlsm
ABCDEFGHIJ
1Job Code 1Job Code 2Job Code 3Job Code 4
2User 1xxxUser 1Job Code 1Training Course 1
3User 2xJob Code 2Training Course 3
4User 3xxJob Code 3
5
6
7
8
9
10
11
12Job Code 1Job Code 2Job Code 3Job Code 4
13Training Course 1xx
14Training Course 2x
15Training Course 3xx
Main
Cell Formulas
RangeFormula
I2:I4I2=TRANSPOSE(FILTER(B1:E1,FILTER(B2:E4,A2:A4=H2,"")="x",""))
J2:J3J2=IFERROR(UNIQUE(FILTERXML("<k><m>"&TEXTJOIN("</m><m>",,IF(FILTER(B13:E15,ISNUMBER(MATCH(B12:E12,I2#,0)),"")="x",A13:A15,""))&"</m></k>","//m")),"")
Dynamic array formulas.

Thank you Fluff & Irobbo both of these solutions work just as I wanted it to. I went with Fluff's as it's a bit easier for me to understand and didn't require me playing with the column/row position depending where I wanted to start in the table.

Irobbo's solution has an option to do a partial match, would it be possible to work that into Fluff's solution?

So if there was a user "John Doe (JDoe)" searching "John" or "John D" would give the same info? I'm not concerned about the incorrect user name getting pulled if there were two Johns.
 
Upvote 0
You could use
Excel Formula:
=TRANSPOSE(FILTER(B1:E1,FILTER(B2:E4,ISNUMBER(SEARCH(H2,A2:A4)),"")="x",""))
but it will fail if you have more than one John in col A
 
Upvote 0
You could use
Excel Formula:
=TRANSPOSE(FILTER(B1:E1,FILTER(B2:E4,ISNUMBER(SEARCH(H2,A2:A4)),"")="x",""))
but it will fail if you have more than one John in col A
This works! I appreciate all your help, it has saved me so much headache.
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0
Another option
+Fluff 1.xlsm
ABCDEFGHIJ
1Job Code 1Job Code 2Job Code 3Job Code 4
2User 1xxxUser 1Job Code 1Training Course 1
3User 2xJob Code 2Training Course 3
4User 3xxJob Code 3
5
6
7
8
9
10
11
12Job Code 1Job Code 2Job Code 3Job Code 4
13Training Course 1xx
14Training Course 2x
15Training Course 3xx
Main

I'm dredging this up again for one last question. I'm looking to make a complete list of all users and their assigned job code.

For instance, using the above example I'm hoping to get an output of:

Job CodeUser
Job Code 1User 1
Job Code 2User 1
Job Code 3User 1
Job Code 3User 2
Job Code 1User 3
Job Code 3User 3

I want the duplicate values displayed as it should be a complete list of what each user is assigned.

Would this be possible in the form I currently have the data laid out (as shown above) or should I try to take a different approach in trying to display this data?
 
Upvote 0
How about
+Fluff 1.xlsm
ABCDEFGH
1Job Code 1Job Code 2Job Code 3Job Code 4
2User 1xxxJob Code 1User 1
3User 2xJob Code 2User 1
4User 3xxJob Code 3User 1
5Job Code 3User 2
6Job Code 1User 3
7Job Code 3User 3
8
Master
Cell Formulas
RangeFormula
G2:G7G2=FILTERXML("<k><m>"&TEXTJOIN("</m><m>",,IF(B2:E4="x",B1:E1,""))&"</m></k>","//m")
H2:H7H2=FILTERXML("<k><m>"&TEXTJOIN("</m><m>",,IF(B2:E4="x",A2:A4,""))&"</m></k>","//m")
Dynamic array formulas.
 
Upvote 0

Forum statistics

Threads
1,215,069
Messages
6,122,958
Members
449,096
Latest member
Anshu121

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