How do I concatenate multiple rows if they are the same / if they equal true?

Hi all,


I'm trying to figure out a way to concatenate numbers from multiple rows based on an "if" statement. Below you'll see my columns and data.


Essentially, I'm trying to figure out how I can:

  1. Find if the 'product id' is the same as the 'product id' in the cell above it
  2. If it is the same (ie TRUE), then grab its image number from the 'Image' column and add it to the 'Concatenated Images' column. If the 'product id' is not the same as the cell above it (ie. FALSE), don't concatenate (leave cell blank)


The end goal is to have a list of all the concatenated numbers from the 'Image' column in one cell , each separate by a comma. For example, the 'Concatenated Images' cell for first row (Product Id 4) would look like: '2308, 2309, 2310, 2311, 3073, 4102, 4757, 4758, 4759'


In the screen shot below, you'll see my current formula. As of now, I'm able to get two values separated by a comma. While this is progress, I still can't figure out how to get all the numbers in the 'Image' column into one cell, separated by commas.


Any insights would be greatly appreciated. Let me know if any of this is vague or confusing and I'll clarify in a follow-up post.


Thanks,

Andrew


Posted on Jan 20, 2019 9:03 AM

Reply
8 replies

Jan 20, 2019 12:41 PM in response to androojones

Hi Andrew,


I'm puzzled by the tokens labeled "Image 4102" and "image 4757" in your formula. The tokens indicate that this is a cell reference, using column and row header labels, but the first two tokes use the column and row index values. Since the preference choice for this applies globally within the document, I'm wondering how this mismatch occurred.


This should do what you have described:


The formula shown below the table is entered in C2, and filled down the rest of the column.


Regards,

Barry


Jan 20, 2019 2:45 PM in response to androojones

CONCATENATE would have worked I think. It looks like you were concatenating a wrong cell. Also, your IF formula did not have the third parameter that said what to do if the result was false.


While it was not a problem, you were also mixing CONCATENATE and the & operator (which does the same job) where you could/should have used one or the other. =CONCATENATE(C1, ", ", B2) is the same as =C1&", "&B2

Jan 20, 2019 8:29 PM in response to androojones

Hi Andrew,


"Evidently, using concatenate for this wasn't going to provide the results I needed."


As Badunit has already noted, CONCATENATE would have produced the same results as &, the concatenation operator. My primary reasons for preferring the operator here are its simpler syntax and shorter formulas.


Regards,

Barry


Thanks for the green checkmark! Always appreciated.


@ **: Thanks for the explanation on cell reference labelling in the newer versions of Numbers. I think I'd find this counter-productive when trouble-shooting a formula—especially if the behaviour is the same with a cell containing an 80 character string, rather than a four digit number!


B.

Jan 21, 2019 5:35 AM in response to Barry

"cell reference labelling in the newer versions of Numbers. I think I'd find this counter-productive when trouble-shooting a formula—especially if the behaviour is the same with a cell containing an 80 character string, rather than a four digit number!'


Hi Barry,


I wasn't sure about that token either. I couldn't reproduce it in Numbers 5.3, even with 'Use header names as labels' checked in Numbers Preferences... until I added a Header Column containing the image numbers, like this:




So the reference is to the column labeled 'Image' and the row labeled '4757'. The '4757' is from the value in the Header Column for that row, not from the value in the cell itself. That is consistent with Numbers for iOS. I find those labels sometimes can be useful in constructing formulas, much like named ranges in Excel. In Numbers for Mac one can always turn off 'Use header names as labels'. That can reduce confusion when posting here.


SG


This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How do I concatenate multiple rows if they are the same / if they equal true?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.