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
UserID16644
Level V

How to do value ordering that has values that contains a specific word?

Hi all,

How can I create a line of code that will arrange my columns using Value Ordering? I needed the values that contains the word "new" to be on the bottom.

Original Values
F1
F2
F3
F4 - NEW
F5
F6 - NEW
F7 
F8
F9 - NEW
F10 - NEW

With Value Ordering
F1
F2
F3
F5
F7 
F8
F4 - NEW
F6 - NEW
F9 - NEW
F10 - NEW

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: How to do value ordering that has values that contains a specific word?

This doesn't get the correct ordering as F10 will be before F4 and so on, but gives an idea what you could do (get two lists, order them, combine them and finally set property)

Names Default To Here(1);

dt = New Table("Untitled",
	Add Rows(10),
	Compress File When Saved(1),
	New Column("A",
		Character,
		"Nominal",
		Set Selected,
		Set Values({"F1", "F2", "F3", "F4 - NEW", "F5", "F6 - NEW", "F7", "F8", "F9 - NEW", "F10 - NEW"})
	)
);

l = {};
lnew = {};

For Each Row(dt,
	If(Ends With(:A, "- NEW"),
		Insert Into(lnew, :A);
	,
		Insert Into(l, :A)
	);
);

final = Sort List(l) || Sort List(lnew);

Eval(EvalExpr(
	Column(dt, "A") << Set Property("Value Order",
		{Custom Order(Expr(final)), Common Order(0)}
	);
));

jthi_0-1728538471886.png

 

-Jarmo

View solution in original post

1 REPLY 1
jthi
Super User

Re: How to do value ordering that has values that contains a specific word?

This doesn't get the correct ordering as F10 will be before F4 and so on, but gives an idea what you could do (get two lists, order them, combine them and finally set property)

Names Default To Here(1);

dt = New Table("Untitled",
	Add Rows(10),
	Compress File When Saved(1),
	New Column("A",
		Character,
		"Nominal",
		Set Selected,
		Set Values({"F1", "F2", "F3", "F4 - NEW", "F5", "F6 - NEW", "F7", "F8", "F9 - NEW", "F10 - NEW"})
	)
);

l = {};
lnew = {};

For Each Row(dt,
	If(Ends With(:A, "- NEW"),
		Insert Into(lnew, :A);
	,
		Insert Into(l, :A)
	);
);

final = Sort List(l) || Sort List(lnew);

Eval(EvalExpr(
	Column(dt, "A") << Set Property("Value Order",
		{Custom Order(Expr(final)), Common Order(0)}
	);
));

jthi_0-1728538471886.png

 

-Jarmo