VLOOKUP Multiple value return in Single Cell with Repitiion

Jeannie11

New Member
Joined
Sep 28, 2019
Messages
3
Hello -

I have a reference value that I'm looking to return the associated values into one cell but am not sure how to do that. For example, assume the reference value is MATH in worksheet 1 and in Worksheet 2 Math is associated with Geometry, Algebra, Statistics. I'd like to return both Geometry and Algebra in one cell in worksheet 1, and separate by commas.

Worksheet 1
AB
MathGeometry, Algebra, Statistics

<tbody>
</tbody>

Worksheet 2
MathGeometry
MathAlgebra
MathStatistics

<tbody>
</tbody>

Thank you in advance!!
 

sandy666

Well-known Member
Joined
Oct 24, 2015
Messages
4,308
With Power Query

Column1Column2Column1Custom
MathGeometryMathGeometry,Algebra,Statistics
MathAlgebra
MathStatistics

Code:
[SIZE=1]// Table1
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Group = Table.Group(Source, {"Column1"}, {{"Count", each _, type table}}),
    Extract = Table.TransformColumns(Table.AddColumn(Group, "Custom", each List.Distinct(Table.Column([Count],"Column2"))), {"Custom", each Text.Combine(List.Transform(_, Text.From), ","), type text})
in
    Extract[/SIZE]
 

Jeannie11

New Member
Joined
Sep 28, 2019
Messages
3
Thank you for replying!

I'm not familiar with what Power Query is and not seeing an icon for it on the Excel. Could you please guide me as to what that means and where I place this code? Assuming I'd need to tweak the code as well so that it looks to the right cells in my spreadsheet.
 

Jeannie11

New Member
Joined
Sep 28, 2019
Messages
3
Ok! I may be doing something wrong because I keep receiving an error... "column1 on the table is not found".
 

AhoyNC

Well-known Member
Joined
Oct 10, 2011
Messages
4,375
Office Version
365
Platform
Windows
If you have Excel 2016 or later with the TEXTJOIN function then here is another option.
This is an array formula and must be entered with CTRL-SHIFT-ENTER.

Excel Workbook
AB
1MathGeometry, Algebra, Statistics
Sheet1
Excel Workbook
AB
1MathGeometry
2MathAlgebra
3HistoryHist1
4HistoryHist2
5MathStatistics
Sheet 2
 

Forum statistics

Threads
1,085,835
Messages
5,386,230
Members
401,986
Latest member
crt54

Some videos you may like

This Week's Hot Topics

Top