Max Crawford
Max Crawford

Reputation: 13

Taking a group of cells and organizing them into a comma separated list in a single cell, arranged in order of percentage in google sheets

Google sheets problem here. I have a group of cells that I'm trying to automate into making the "ingredient list" in a nutrition facts cell for food products. I'll have in one row for example, carrots, onion, tomatoes, sugar. In the cell next to it, I'll have the corresponding percentage. What I need, is to have each item sent to a single cell so that it looks like a plain sentence. For example, if the info was carrots 22%, onions 33%, tomatoes 12%, and sugar 5%, the information would read "Ingredients: Onions, Carrots, Tomatoes, Sugar. Thank you in advance for your help. This one has been giving me a headache.

Sample Sheet

Here is a screenshot of my current sheet. As you can see, there are the two circled columns and the arrow pointing to the "ingredients" cell. I need the cells that are circled to be listed in the "ingredients" cell in order of percentage from highest to lowest, separated by commas.

Update: I have been able to figure out how the list the cells, but I can't figure out how to organize them by percentage. Here is the formula I'm currently using.

=CONCATENATE(F2,",",F3,",",F4,",",F5)

enter image description here

Upvotes: 0

Views: 365

Answers (1)

Assad Z
Assad Z

Reputation: 1

try this: =TEXTJOIN(", ", true, sort(A2:A13,B2:B13, false))

Where A2:A13 is the column for ingredients and B2:B13 is the column for Total %.

enter image description here

Upvotes: 0

Related Questions