cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
The Discovery Summit 2025 Call for Content is open! Submit an abstract today to present at our premier analytics conference.
Choose Language Hide Translation Bar
uProf
Level III

Order level based on last 3 characters of value

Hi -

 

I would like to have order of values on x axis in plot to be in ascending order. Issue is these values are alphanumeric strings and only last 3 characters are the ones that indicate order.

 

For example, I would like to see these in following order from left to right on a plot. 

 

1: YRFCA1

2: YRTCB1

3: YRACB2

4: YRTCC0

 

Row and Value order levels arranged data in a different way. 

 

I could do substring of values above and focus only on last 3 characters before ordering them but am not sure how to display entire 6 character string in the plot.

 

Appreciate input on how I could implement this in JSL.

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Craige_Hales
Super User

Re: Order level based on last 3 characters of value

5 REPLIES 5
Craige_Hales
Super User

Re: Order level based on last 3 characters of value

Maybe something like this. I created the transform column in the GUI, then saved it. Right-click the variable to transform (in the column selector), choose transform->formula. Then drag/drop the new transform variable into graph builder.

Graph Builder(
	Size( 893, 823 ),
	Show Control Panel( 0 ),
	Variables(
		X( :name ),
		Y(
			Transform Column(
				"Transform[name]",
				Character,
				Nominal,
				Formula(
					Right( :name, 3 ) || "_" || Left( :name, Length( :name ) - 3 )
				)
			)
		)
	),
	Elements( Points( X, Y, Legend( 8 ) ) )
);

Last three letters moved to front of nameLast three letters moved to front of name

Craige
ZF
ZF
Level III

Re: Order level based on last 3 characters of value

I sort the table by the last 3 character (get the substring of the last 3 char first), then set property of the long text column "value ordering" .

Names default to here(1);
dt=New Table( "order by another col",
	Add Rows( 4 ),
	New Column( "Label",
		Character,
		"Nominal",
		Set Values( {"YRFCA1", "YRTCB1", "YRACB2", "YRTCC0", "YAAAA4"} )
	),
	New Column( "Last 3",
		Character,
		"Nominal",
		Formula( Right( :Label, 3 ) ),
),
);
dt << sort(replace table(1), by(:Last 3));
values=dt:Label << get values;
dt:Label << set property ("Value Ordering", values);

value order.PNG

 

Craige_Hales
Super User

Re: Order level based on last 3 characters of value

Nice!

Craige
uProf
Level III

Re: Order level based on last 3 characters of value

Both ways are very helpful. Thanks Craige and ZF! 

jthi
Super User

Re: Order level based on last 3 characters of value

You can also "force" JMP to use ordering of non-numeric columns through JSL, but this might be a bug and not a feature so might be a bit risky to use:

 

Names Default To Here(1);
dt = New Table("table",
	Add Rows(5),
	New Column("Col", Character, "Nominal", Set Values({"YRFCA1", "YRTCB1", "YRACB2", "YRTCC0", "YAAAA4"})),
	New Column("order", Character, "Nominal", Formula(Right(:Col, 3)))
);

dt = Graph Builder(Variables(X(:Col, Order By(:order, Ascending))), Elements(Points(X, Legend(34))));

jthi_3-1629057195639.png

 

You can do it also directly from Graph builder by using two x-axis label rows:

 

jthi_0-1629056980602.png

Then if you want to you canopen x-axis settings and then do some modifications to other label's settings to hide it (in this case order):

jthi_1-1629057085369.png

and you end up with:

jthi_2-1629057094683.png

Then you could change the x-axis to remove the order /.

 

-Jarmo