18

I have the following string in column H and I.

H2="http://"
I2="aaa"
H3="http://"
I3="bbb"

I want to have a auto-generated J column, which results like:

J2="http://aaa"
J3="http://bbb"

So I put the following formula in J1:

= ARRAYFORMULA (IF(ROW(J:J)=1;"formulaTest";CONCATENATE(H:H1, I:I1 ) ))

But the result I got is:

J2="http://http://aaabbb"
J3="http://http://aaabbb"

What is going wrong with my formula?

4 Answers 4

26

This is what you are looking for:

=ARRAYFORMULA((IF(ROW(J:J)=1,"formulaTest",H1:H & I1:I)))
3
  • 3
    Great! It finally works now!. Though I still don't know why I can not use "CONCATENATE", instead I need to use "&" in this formula.
    – srjohnhuang
    Jan 17, 2014 at 6:53
  • 3
    @srjohnhuang With the CONCATNATE, the complete column range is fed to the ARRAYFORMULA. Using the ampersand, only the single entries are fed, giving you the desired result.
    – Jacob Jan
    Jan 19, 2014 at 12:01
  • 3
    The reason you can use & but not concatenate() is that concatenate can take a range whereas & can only join specific discreet values.
    – user72987
    Jun 30, 2014 at 18:50
15

In Google Sheets, the simplest solution is to just use CONCAT instead of CONCATENATE.

=ARRAYFORMULA(CONCAT(H1:H,I1:I))

CONCAT will return only two values and can be used in this manner for an array formula. You cannot use CONCATENATE because (as mentioned by others) it will return the whole array.

1
  • 11
    Or even shorter, =arrayformula(H1:H & I1:I)
    – user135384
    Jan 15, 2018 at 5:52
2

Formula

=ARRAYFORMULA(UNIQUE(IF(V2:V="","",(CONCAT(CONCAT(V2:V," - "),W2:W)))))

Functions

  1. ARRAYFORMULA -   Enables applying the formula to an entire column
  2. UNIQUE -   Removes duplicates from the results
  3. IF: Tests if column V is empty using V2:V=""
    1. 'value_if_true' is an empty string ""
    2. 'value_if_false' is two nested CONCAT functions
      CONCAT(CONCAT(V2:V; " - "); W2:W)
      1. Nested one joins column V with " - "
      2. Outer one joins nested one with column W return nothing, otherwise
0
0

Here is what I use for concating multiple columns with a glue string:

=ARRAYFORMULA(IF(ISBLANK(A2:A) ,, IFERROR(H2:H & "-" & I2:I ,'Attention!')))

the IF(ISBLANK(A2:A) part is added so that ARRAYFORMULA does not perform on empty rows of the sheet.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.