SOLVED

Multistep: Lookup values based on another table and then concatenate by an ID

%3CLINGO-SUB%20id%3D%22lingo-sub-2820046%22%20slang%3D%22en-US%22%3EMultistep%3A%20Lookup%20values%20based%20on%20another%20table%20and%20then%20concatenate%20by%20an%20ID%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2820046%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Everyone%2C%20thank%20you%20in%20advance%20for%20any%20help%20you%20are%20able%20to%20provide!%20I%20consider%20myself%20good%20at%20excel%20and%20power%20query%20but%20this%20is%20quite%20a%20beast%20in%20my%20opinion.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3EDevice%20and%20OS%20platform%3A%3C%2FSTRONG%3E%20PC%2C%20Windows%2010%3C%2FP%3E%3CP%3E%3CSTRONG%3EExcel%20product%20name%20and%20version%20number%3A%3C%2FSTRONG%3E%20Excel%202102%3C%2FP%3E%3CP%3E%3CSTRONG%3EAs%20much%26nbsp%3Bcontext%26nbsp%3Bof%26nbsp%3Bwhat%26nbsp%3Byou're%20trying%20to%20do%20-%20and%26nbsp%3Bwhy%3A%3C%2FSTRONG%3E%3C%2FP%3E%3CUL%3E%3CLI%3E(I%20added%20notes%20in%20the%20excel%20file%20as%20well%20that%20should%20be%20useful)%26nbsp%3B%3C%2FLI%3E%3CLI%3EThe%20overall%20goal%20of%20this%20is%20to%20generate%20a%20series%20of%20key%20words%20at%20the%20ID%20level%20based%20off%20comparing%20the%20lookup%20table%20(name)%20to%20the%20descriptions%20within%20each%20Key_ID.%26nbsp%3B%3C%2FLI%3E%3CLI%3EI%20am%20trying%20to%20use%20a%20lookup%20table%20to%20identify%20certain%20words%20in%20a%20Description%20(1%20description%20per%20row)%20and%20then%20in%20a%20new%20column%20(Results)%20have%20the%20%22keyword%22%20appear.%20Then%20In%20another%20new%20column%20(All%20Results%20per%20ID)%20concatenate%26nbsp%3Ball%20keywords%20together%20by%20key_ID%20from%20every%20row%20within%20that%20key_ID.%3C%2FLI%3E%3CLI%3EThen%20finally%2C%20I%20want%20to%20take%20the%20All%20Results%20per%20Key_ID%2C%20and%20translate%20that%20into%20Type%26nbsp%3B(same%20lookup%20table)%20summarized%20at%20a%20Key_ID%20level%3C%2FLI%3E%3C%2FUL%3E%3CP%3E%3CSTRONG%3EExpected%20Result%20and%20Method%3A%3C%2FSTRONG%3E%3C%2FP%3E%3CUL%3E%3CLI%3EI%20believe%20Power%20Query%20or%20VBA%20is%20probably%20the%20best%20route%20to%20go%2C%20but%20if%20it%20can%20be%20done%20in%20normal%20excel%20that%20would%20also%20work.%20I%20had%20envisioned%20this%20as%20almost%20a%20conditional%20column%20in%20Power%20Query%20with%20a%20few%20tweaks%20but%20I%20have%20not%20had%20any%20success%20in%20that%20regard.%20An%20important%20point%20to%20note%20is%20that%20tables%20cannot%20be%20merged%20it%20won't%20align%20properly%20given%20the%20data%20I'm%20working%20with.%20I%20am%20not%20as%20familiar%20with%20VBA%20vs%20Excel%20%26amp%3B%20Power%20Query%2C%20so%20I%20have%20not%20explored%20that%20option.%26nbsp%3B%3C%2FLI%3E%3C%2FUL%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2820046%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2820564%22%20slang%3D%22en-US%22%3ERe%3A%20Multistep%3A%20Lookup%20values%20based%20on%20another%20table%20and%20then%20concatenate%20by%20an%20ID%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2820564%22%20slang%3D%22en-US%22%3E%3CP%3EAssuming%20you%20have%20Microsoft%20365%20(subscription%20version)%2C%20you%20may%20use%20the%20following%20formulas%20for%20cells%20C3%20to%20E3%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E%3DTEXTJOIN(%22%2C%20%22%2CTRUE%2CFILTER(J%243%3AJ%246%2CISNUMBER(SEARCH(J%243%3AJ%246%2CB3))%2C%22%22))%0A%20%0A%3DTEXTJOIN(%22%2C%20%22%2CTRUE%2CUNIQUE(FILTER(C%243%3AC%248%2CA%243%3AA%248%3DA3%2C%22%22)))%0A%20%0A%3DTEXTJOIN(%22%2C%20%22%2CTRUE%2CUNIQUE(FILTER(VLOOKUP(C%243%3AC%248%2CJ%243%3AK%246%2C2%2CFALSE)%2CA%243%3AA%248%3DA3%2C%22%22)))%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2823684%22%20slang%3D%22en-US%22%3ERe%3A%20Multistep%3A%20Lookup%20values%20based%20on%20another%20table%20and%20then%20concatenate%20by%20an%20ID%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2823684%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F852471%22%20target%3D%22_blank%22%3E%40byundt%3C%2FA%3E%26nbsp%3BThank%20you!%20That%20worked%20almost%20perfectly.%20The%20only%20issue%20I'm%20having%20now%20is%20with%20the%203rd%20statement%20if%20there%20are%20blanks%20in%20the%20rows%20it%20returns%20N%2FA.%20Do%20you%20have%20any%20advice%20for%20that%20issue%3F%20Thanks%20again.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2823790%22%20slang%3D%22en-US%22%3ERe%3A%20Multistep%3A%20Lookup%20values%20based%20on%20another%20table%20and%20then%20concatenate%20by%20an%20ID%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2823790%22%20slang%3D%22en-US%22%3E%3CP%3EThe%20suggested%20formulas%20return%20an%20empty%20string%20(looks%20like%20a%20blank)%20if%20the%20corresponding%20values%20in%20columns%20A%20or%20B%20are%20blank.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20can%20make%20the%20third%20formula%20return%20%23N%2FA%20if%20your%20lookup%20table%20contains%20blank%20cells%20(not%20a%20good%20practice).%20If%20that's%20your%20problem%2C%20you%20can%20overcome%20it%20using%3A%3C%2FP%3E%3CP%3E%3DTEXTJOIN(%22%2C%20%22%2CTRUE%2CUNIQUE(FILTER(IFNA(VLOOKUP(C%243%3AC%248%2CJ%243%3AK%246%2C2%2CFALSE)%20%26amp%3B%20%22%22%2C%22%22)%2CA%243%3AA%248%3DA3%2C%22%22)))%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

Hi Everyone, thank you in advance for any help you are able to provide! I consider myself good at excel and power query but this is quite a beast in my opinion. 

 

Device and OS platform: PC, Windows 10

Excel product name and version number: Excel 2102

As much context of what you're trying to do - and why:

  • (I added notes in the excel file as well that should be useful) 
  • The overall goal of this is to generate a series of key words at the ID level based off comparing the lookup table (name) to the descriptions within each Key_ID. 
  • I am trying to use a lookup table to identify certain words in a Description (1 description per row) and then in a new column (Results) have the "keyword" appear. Then In another new column (All Results per ID) concatenate all keywords together by key_ID from every row within that key_ID.
  • Then finally, I want to take the All Results per Key_ID, and translate that into Type (same lookup table) summarized at a Key_ID level

Expected Result and Method:

  • I believe Power Query or VBA is probably the best route to go, but if it can be done in normal excel that would also work. I had envisioned this as almost a conditional column in Power Query with a few tweaks but I have not had any success in that regard. An important point to note is that tables cannot be merged it won't align properly given the data I'm working with. I am not as familiar with VBA vs Excel & Power Query, so I have not explored that option. 

 

5 Replies
best response confirmed by Joe_JL (Occasional Contributor)
Solution

Assuming you have Microsoft 365 (subscription version), you may use the following formulas for cells C3 to E3:

=TEXTJOIN(", ",TRUE,FILTER(J$3:J$6,ISNUMBER(SEARCH(J$3:J$6,B3)),""))
 
=TEXTJOIN(", ",TRUE,UNIQUE(FILTER(C$3:C$8,A$3:A$8=A3,"")))
 
=TEXTJOIN(", ",TRUE,UNIQUE(FILTER(VLOOKUP(C$3:C$8,J$3:K$6,2,FALSE),A$3:A$8=A3,"")))

 

@byundt Thank you! That worked almost perfectly. The only issue I'm having now is with the 3rd statement if there are blanks in the rows it returns N/A. Do you have any advice for that issue? Thanks again.

The suggested formulas return an empty string (looks like a blank) if the corresponding values in columns A or B are blank. 

 

I can make the third formula return #N/A if your lookup table contains blank cells (not a good practice). If that's your problem, you can overcome it using:

=TEXTJOIN(", ",TRUE,UNIQUE(FILTER(IFNA(VLOOKUP(C$3:C$8,J$3:K$6,2,FALSE) & "",""),A$3:A$8=A3,"")))

The formula I you just added worked great, thank you! Out of curiosity why is having blanks not best practice? My lookup table does not have blanks but some of the rows might contain no key words and so the row would be blank. Do you have a recommended best practice instead?

When you import data from elsewhere, it often has blanks. If so, Excel formulas have to deal with them. A formula returning a value from a blank cell will display the result as 0. A formula lookup up a value in a blank cell returns #N/A error value. Excel formulas have to deal with these problems because you cannot avoid the blank cells at design time.

It's when you are creating the lookup table yourself that the "good practice" assertion comes into play. There is no need for blank rows in the lookup table. If you want white space between groups, change the row height to provide it. The #N/A problem you encountered is a bit of an "own goal" problem to my mind. Sure, someone like me can redesign the formula to overcome it. But you were stuck, and entirely due to something under your control. That's why I said "not a good practice."