cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar

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);

3 ACCEPTED SOLUTIONS

Accepted Solutions

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".

 

View solution in original post

cwillden
Super User (Alumni)

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)") )
	)
);
-- Cameron Willden

View solution in original post

dale_lehman
Level VII

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 )

View solution in original post

8 REPLIES 8

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".

 

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

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

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.

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

cwillden
Super User (Alumni)

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)") )
	)
);
-- Cameron Willden
dale_lehman
Level VII

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 )

Re: Concatenate values in a column

Thank you so much for everyone's help. My issue has been sloved.