Logical Test to check a range and return True or FalseHi,
l am trying to check if a value in a cell within a variable lies within a range of values, between 0.50 and 2.0, and if it does fall within that range to return true and if it doesnt return false. i am in the data table, and column info, and typing the following into the edit formula:
If (0.50 < ( :Name( "P1-R1-D1-L1" ) > 2.0), "True", "False") <BR /><BR />// and
<BR />If (0.50 < ( :Name( "P1-R1-D1-L1" ))|(2.0 > ( :Name( "P1-R1-D1-L1" ), "True", "False"))
but neither is working for me, what am i doing wrong, any help would be greatly appreciated
Thanks
Re: Logical Test to check a range and return True or Falseonce again thanks txnelson, thanks for all your help, greatly appreciatedRe: Logical Test to check a range and return True or FalseThanks Jeff, great explanation
Re: Logical Test to check a range and return True or False@txnelson gave you a working example but I can explain what you've got wrong in your attempts.
If (0.50 < ( :Name( "P1-R1-D1-L1" ) > 2.0), "True", "False")
In this on you're trying a complex comparison that JMP doesn't support, namely a < b > c, i.e. a less than b greater than c.
Looking in the Formula Editor you can see the complex comparisons that JMP does offer, and that @txnelson used:

Notice the help text which gives a clue that JMP is a functional language and that these complex operators are really shorthand for the functions Less LessEqual() and LessEqual Less(). JMP doesn't have a function for the comparison you wanted to make.
For the second attempt:
If (0.50 < ( :Name( "P1-R1-D1-L1" ))|(2.0 > ( :Name( "P1-R1-D1-L1" ), "True", "False"))
You've got some more parentheses than needed and they are in the wrong places. Here's a corrected version:
If( 0.50 < :Name( "P1-R1-D1-L1" ) | 2.0 > :Name( "P1-R1-D1-L1" ),
"True",
"False"
)
However, let's consider what you're asking for in this logical comparison. You're asking JMP to check whether your column is greater than .5 or 2.0 is greater than your column. This will be true for all values of your column. If your column is less than .5, then 2.0 will be greater than your column. If your column is greater than 2.0 then .5 will be less than your column.
So, you probably want the version that @txnelson provided, checking to see if your column is within the range .5 to 2.0 using the a < b <= c construct.
Re: Logical Test to check a range and return True or FalseHere is a piece of JSL that creates a column under the specifications you provided
Names Default To Here( 1 );
dt = New Table( "Example",
add rows( 20 ),
New Column( "P1-R1-D1-L1", formula( Random Uniform( 0, 4 ) ) )
);
dt << New Column( "TorF",
character,
formula( If( 0.50 <= :Name( "P1-R1-D1-L1" ) <= 2.0, "True", "False" ) )
);