cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar

JMP Scripting- How to change the value of a "cell"

Hi,

I am wondering how to script it to change the value of a "cell" that is a result of a calculation in the script.

Specifically, I want to be able to change a value of a cell to "0" if the calculated value is negative while leaving all other "cells" alone.

Even if it needs to be in a new column, that is fine. For example, If i have my column of calculated values and the one I care about is negative, create a new column that would just say "0" for that "cell."

Thanks in advance.

13 REPLIES 13
txnelson
Super User

Re: JMP Scripting- How to change the value of a "cell"

you can certainly make the conditional checking part of the formula

Jim
txnelson
Super User

Re: JMP Scripting- How to change the value of a "cell"

You have to change the formula to check for the value that you want to change, and then use a conditional statement in the formula to change it to the value you want.

// Sample formula
:A + :B;
If( isMissing(:A+:B) == 1, 0 );
Jim
pmroz
Super User

Re: JMP Scripting- How to change the value of a "cell"

Can you post the formula?  As txnelson​ said you can simply make the checking part of the formula. 

To post the formula:

1. Open your dataset and click on the + sign next to the formula column. 

2. Double-click inside the formula window.  This will change the window to show the JSL code for the formula

3. Copy the JSL code and post it to this forum.

The new formula will be something like this:

tmp = put-original-formula-here;

if (tmp < 0, 0, tmp);

johnpjust
Level III

Re: JMP Scripting- How to change the value of a "cell"

one liner....

 

dt[dt<< get rows where(:ageval < 14)] = 0;