justdoitmikey
justdoitmikey

Reputation: 1

Google Sheets - Repeat a function a specific number of times

I'm new to Google Sheets so excuse me if this isn't super clear. I have a master document (sheet 2) with a list of names and items for past purchases (sorted by name), for instance:

Name Item Size
Joe Green Tee Size Medium
Joe Red Tee Size Medium
Joe Blue Tee Size Medium

I then have a separate tab (sheet 1) with a list of names for current orders. What I want to do is list all previous orders in one cell next to Joe's current order. So I am looking for a way to lookup all Joe's previous orders and then essentially concatenate them into one cell.

I can write a Vlookup() or match and index but I don't know how to make it repeat the specific number of times for each change in person.

I can use the filter function which returns exactly what I want but it spills into the next cells which doesn't work since each row is another person, so the data needs to be confined to one cell / row per person.

Thanks for any help you can give, I know there is a simple way to do this it just eludes me.

Upvotes: 0

Views: 366

Answers (1)

Harun24hr
Harun24hr

Reputation: 36840

You can try TEXTJOIN() with FILTER() function. Try-

=TEXTJOIN(", ", TRUE, FILTER(Sheet2!$B$2:$B,Sheet2!$A$2:$A=A2))

Or JOIN() function like-

=JOIN(", ",FILTER(Sheet2!$B$2:$B,Sheet2!$A$2:$A=A2))

Reference:

Upvotes: 1

Related Questions