A slight disadvantage of this code: The variables in the Formula will not be defined anymore at a later time.
This can be seen by the red wiggles in the Formula Editor:
The result: When a value in the table changes in the future, the column will not be updated automatically.
A more robust code can be generated with an approach that I learned from @jthi :
Put NameExpr(As Column()) inside Expr().
Then the Formula will look like this:
and column values will update in the future if input values get updated
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
colSelect ="age";
quantVal1 = 13;
quantVal2 = 16;
//Custom Quantiles amounts
Eval(Eval Expr(dt << New Column( "Categories",
Numeric, "Continuous",
Format( "Best", 9 ),
Formula(
If( Expr( NameExpr(As Column(dt, colSelect)) )/*:Total Time From CheckIn Collector To Exit*/ <= Expr(quantVal1),
1,
If( Expr( Name Expr(As Column(dt, colSelect)) )/*:Total Time From CheckIn Collector To Exit*/ <= Expr(quantVal2),
2,
3
)
)
),
Set Property( "Value Order", {} ),
Set Property(
"Color Gradient",
{{"Green to Orange to Red", 4099, {{0, 227, 0}, {255, 255, 0}, {252, 11, 11}}, {0, 0.5, 1}}, Range( {1, 3, 1} )}
),
Color Cell by Value,
Set Display Width( 74 )
)));
dt:age[12]=40;