Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to concatenate words with a separator based on values in other column?

I have in column A a list of 0’s and 1’s. In column B I have words.

COL A COL B
1 BROWN
0 BLACK
0 ORANGE
1 WHITE
1 BLUE
1 GREEN
0 GRAY

I´d like to concatenate the words for those rows in column A that are equal to 1.

My current formula is =CONCAT(IF(A1:A7=1,B1:B7," + ")) and my current output is BROWN + + WHITEBLUEGREEN +

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

My expected output is BROWN + WHITE + BLUE + GREEN. I’m using Excel 365. Thanks

enter image description here

>Solution :

Instead of CONCAT() use TEXTJOIN()

enter image description here


=TEXTJOIN(" + ",1,IF(A2:A8,B2:B8,""))

Or, Could have used FILTER() with TEXTJOIN()

=TEXTJOIN(" + ",,FILTER(B2:B8,A2:A8))

Also, if you intent in using CONCAT() then you could use in this way, but it too much verbose uses one more function to parse the first delimiter.

=SUBSTITUTE(CONCAT(IF(A2:A8," + "&B2:B8,""))," + ",,1)

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading