- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Concatenate values in a column
Hello all,
I am trying to create a new column that concatenates column A, B and C together. The example and the script is showing bellow. The script doesn't work. could someone help me with it?
Thanks,
A B C
dt_summary << new column("Category", string,
formula(:Name( "Frame Config" ) || "_" ||:Name( "Bar Spacing (mm)" )||"_"||:Name( "Clamping Spacing (mm)" )),
eval formula);
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Concatenate values in a column
dt_summary << New Column( "Category",
Character,
Formula(
:Name( "Frame Config" ) || "_" || :Name( "Bar Spacing (mm)" ) || "_" ||
:Name( "Clamping Spacing (mm)" )
)
);
The data type is "character" not "string".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Concatenate values in a column
I'm not sure about the "stacking" stuff in the error since you're not stacking columns here, but I would expect an error from concatenating numeric values without converting them to character strings first. Wrap each numeric column in your formula in char().
dt_summary << New Column( "Category",
Character,
Formula(
:Name( "Frame Config" ) || "_" || char(:Name( "Bar Spacing (mm)" )) || "_" ||
char(:Name( "Clamping Spacing (mm)") )
)
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Concatenate values in a column
I did it with a formula, but you should be able to script it from this. Yes, the columns must be character types to concatenate, and to insert the - you surround it in quotes:
:Column 1 || "-" || Char( :Column 2 ) || "-" || Char( :Column 3 )
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Concatenate values in a column
dt_summary << New Column( "Category",
Character,
Formula(
:Name( "Frame Config" ) || "_" || :Name( "Bar Spacing (mm)" ) || "_" ||
:Name( "Clamping Spacing (mm)" )
)
);
The data type is "character" not "string".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Concatenate values in a column
Thank you so much for your quick response!
There is an error message showing: Cannot stack. Stacked columns are of different data type
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Concatenate values in a column
I am wondering if there is anyway that allow me show something like "3-bar-1000-400" in my new column.
Thanks a lot,
Winnie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Concatenate values in a column
I apologize for my post that suggested stacking. I misunderstood your request. I wan't fast enough at replacing it with a solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Concatenate values in a column
Hi Mark,
Thank you so much again. I have changed script based on your deriction, but the new column is empty. I'm wondering if I can concatenate different data type in jmp?
Thanks,
Winnie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Concatenate values in a column
I'm not sure about the "stacking" stuff in the error since you're not stacking columns here, but I would expect an error from concatenating numeric values without converting them to character strings first. Wrap each numeric column in your formula in char().
dt_summary << New Column( "Category",
Character,
Formula(
:Name( "Frame Config" ) || "_" || char(:Name( "Bar Spacing (mm)" )) || "_" ||
char(:Name( "Clamping Spacing (mm)") )
)
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Concatenate values in a column
I did it with a formula, but you should be able to script it from this. Yes, the columns must be character types to concatenate, and to insert the - you surround it in quotes:
:Column 1 || "-" || Char( :Column 2 ) || "-" || Char( :Column 3 )
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Concatenate values in a column
Thank you so much for everyone's help. My issue has been sloved.