- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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!
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Order level based on last 3 characters of value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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 name
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Order level based on last 3 characters of value
Nice!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Order level based on last 3 characters of value
Both ways are very helpful. Thanks Craige and ZF!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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))));
You can do it also directly from Graph builder by using two x-axis label rows:
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):
and you end up with:
Then you could change the x-axis to remove the order /.