SOLVED

Need help on CONCAT function for multiple column values

Copper Contributor
COL1COL2COL3CONCAT RESULT
B97202DPP('B972','02','DPP');
    
    
    
13 Replies

Hi @Srikanth0990 

 

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)

@Jihad Al-Jarady It's not working as expected

best response confirmed by Srikanth0990 (Copper Contributor)
Solution
Do you want the result to be this: ('B972','02','DPP');
If yes, this the formula
=CONCAT("('",A1,"','",B1,"','",C1,"');")

@Srikanth0990 

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

=ARRAYTOTEXT(A2:C2,1)
If I use Arraytotext getting like below
{"B972",2,"DPP"}

@Srikanth0990 

As variant

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

 

It works, Thank you!
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')

@Srikanth0990 

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

image.png

?

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

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

@Srikanth0990 

That could be

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

 

1 best response

Accepted Solutions
best response confirmed by Srikanth0990 (Copper Contributor)
Solution
Do you want the result to be this: ('B972','02','DPP');
If yes, this the formula
=CONCAT("('",A1,"','",B1,"','",C1,"');")

View solution in original post