3

Sample spreadsheet

I've been trying for the life of me to figure out how to do this and cannot.

I have a table: ColA is items, ColB is their category.

Item Category
Apple Fruit
Orange Fruit
Cauliflower Vegetable
Rose Flower
Tulip Flower
Steak Meat
Carrot Vegetable
Salmon Meat

I'd like to make a new table that has ColD (Categories) and ColE (all the items that belong in that category).

Category Items
Fruit Apple, Orange
Vegetable Cauliflower, Carrot
Meat Steak, Salmon
Flower Rose, Tulip

Currently, I can do that with this formula:

=ARRAYFORMULA(CONCATENATE(REPT(A3:A&" ",B3:B=G3)))

The problem is I need this to be written as an ArrayFormula. CONCATENATE (and other alternatives like FILTER, JOIN) don't work.

Any help would be so appreciated, thank you!

New contributor
coltzans is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
2
  • You wrote "I need this to be written as an ArrayFormula", but then provided an example that is written as an ArrayFormula. Was that a mistake? Or is there something else you need written as an AF? Commented yesterday
  • Ooh to clarify, the ARRAYFORMULA in the code I provided is running an array on the CONCATENATE/REPT to get an output in that single cell. But I would need a formula that doesn't require me to copy it into every cell in the column. Commented 16 hours ago

1 Answer 1

1
You can try with a formula like this one:


=BYROW(TOCOL(UNIQUE(B3:B),1),LAMBDA(category,
HSTACK(category,  TEXTJOIN(", ",0,      FILTER(A3:A,B3:B=category)))))

With TOCOL(UNIQUE(B3:B),1) you grab the categories, with BYROW you loop through them, and then stack the category with the filtered values joined by ", " separator

Sign up to request clarification or add additional context in comments.

1 Comment

AMAZING THANK YOU! This was exactly what I needed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.