 SOLVED

# Need help on CONCAT function for multiple column values

 COL1 COL2 COL3 CONCAT RESULT B972 02 DPP ('B972','02','DPP');
13 Replies

# Re: Need help on CONCAT function for multiple column values

This is the formula for using concat is this, Concat(col1,col2,col3), and

=CONCAT(A2,B2,C2)

if you want to add space between values:

=CONCAT(A2," ",B2," ",C2)

# Re: Need help on CONCAT function for multiple column values

best response confirmed by Srikanth0990 (Occasional Contributor)
Solution

# Re: Need help on CONCAT function for multiple column values

Do you want the result to be this: ('B972','02','DPP');
If yes, this the formula
=CONCAT("('",A1,"','",B1,"','",C1,"');")

# Re: Need help on CONCAT function for multiple column values

Depending on how precise you need the result to be, you might simply use:

``=ARRAYTOTEXT(A2:C2,1)``

# Re: Need help on CONCAT function for multiple column values

If I use Arraytotext getting like below
{"B972",2,"DPP"}

# Re: Need help on CONCAT function for multiple column values

As variant

``="('" & TEXTJOIN("','", 1, A2:C2) & "')"``

# Re: Need help on CONCAT function for multiple column values

It works, Thank you!

# Re: Need help on CONCAT function for multiple column values

How it works if I include COL3

COL1 COL2 COL3 COL4 Result
B972 02 DPP INSERT INTO TABLE VALUES INSERT INTO TABLE VALUES('B972','02','DDP')
B9FD 02 DPP INSERT INTO TABLE VALUES INSERT INTO TABLE VALUES('B9FD','02','DDP')
B976 AB DPP INSERT INTO TABLE VALUES INSERT INTO TABLE VALUES('B976','AB','DDP')

# Re: Need help on CONCAT function for multiple column values

Sorry, I didn't catch. Do you mean it shall be like ?

# Re: Need help on CONCAT function for multiple column values

I need to include this INSERT INTO TABLE VALUES in Result 1 columns

Result1 should be
INSERT INTO TABLE VALUES('B972','02','DDP')

# Re: Need help on CONCAT function for multiple column values

That could be

``="INSERT INTO TABLE VALUES('" & TEXTJOIN("','", 1, A2:C2) & "')"``

Thanks a ton!!

You are welcome