Combine two cell values into one cell

Chakra shared this question 6 years ago
Answered

Hi,

Is there a way to combine two row values into one row with a comma as a separator ?

For Instance

Product name Usage

Laptop ALL IT

Laptop Everyone

Desktop IT

_____________________

Desired Results

Product Name Usage

Laptop ALL IT, Everyone

Desktop IT

Appreciate if someone can please asssist me on this.


Thank you,

Chakri.

Replies (8)

photo
1

Anything on this please?

photo
1

Hi Chakra,

Thank you for reaching out. This should be possible. I took two columns, First Name and Last Name and made it display in one column as "Last Name, First Name".

Here's what I did:

I created a Calculated Field > Simple > chose Last Name + ',':

I then applied an Advanced Function to this Calculated Field like so:

/z9GgYzK38KfWgAAAABJRU5ErkJggg==

Now here are the original results for First Name, Last Name and now the Addition of First Name column to my Last Name + ',' Calculated Field:

In your case you'd create a calculated field adding a ',' to the column where your value ends in "IT" so it will display as "IT," then concatenate columns under Advanced Function for the created calculated field, selecting the column that features the "Everyone" value.

Please let me know if you have any further questions.

Regards,

Mike

photo
1

Hi Mike,

Thanks for the details and screenshot. However, I'm not looking to concatenate multiple columns into one.

I'm looking to combine result from a single column. Please refer to the attached screenshot for more details.

Thank you,

Chakra

photo
1

Hi Chakra,

Sorry, I misunderstood. Couldn't tell what was a column and what was a row based on the text. The screenshot gives me what you're looking for now though. There's a community item on exactly this that you can reference to accomplish this: Aggregate a text column. It is a little complicated, but it should get you to what you're after.

Regards,

Mike

photo
1

Hi Chakra,

I just wanted to check in and see how things are going with this.

Regards,

Mike

photo
1

Hi Mike,

I was unable to achieve this because String_Agg (for SQL Server) is not comparable with JDBC.

Other than what you have provided, it doesn't seem to have any OOTB functions to achieve this.

Thank you,

CT.

photo
1

Hi Chakra,

Which Driver are you using with MS SQL Server? I'm pretty sure the jTDS driver is compatible with JDBC and should accept T-SQL statements such as these.

Regards,

Mike

photo
1

Hi Chakra,

I'm going to go ahead and mark this one as Answered since I haven't heard back, but if you have further questions or concerns on this, if you respond, it will re-open the case and put it back in my queue and I'll be happy to help.

Regards,

Mike

Leave a Comment
 
Attach a file