cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
spirotodd
Level II

Creating and filling a new column with a formula

Hello,

I am attempting to use a script to generate a new column called "Sensor Power (W)" that takes the following formula:

Sensor Power (W) = ( Sensor Voltage x Sensor Current ) / 1000000

where Sensor Voltage and Sensor Current are formulas that already exist (in mV and mOhms).

 

Thanks,
Todd

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Creating and filling a new column with a formula

Here is the simple script that will do what you requested

Names Default To Here( 1 );
dt = Current Data Table();
dt << New Column( "Sensor Power", formula( :Sensor Voltage * :Sensor Current / 1000000 ) );
dt:Sensor Power << set property( "Units", "W" );
Jim

View solution in original post

5 REPLIES 5
txnelson
Super User

Re: Creating and filling a new column with a formula

Here is the simple script that will do what you requested

Names Default To Here( 1 );
dt = Current Data Table();
dt << New Column( "Sensor Power", formula( :Sensor Voltage * :Sensor Current / 1000000 ) );
dt:Sensor Power << set property( "Units", "W" );
Jim
spirotodd
Level II

Re: Creating and filling a new column with a formula

Thank you. I have another question.

I have a column in the table that lists Date/Time. I would like to generate a new column that lists the date and time separately. Is there a script command to do this?

Thanks.
txnelson
Super User

Re: Creating and filling a new column with a formula

There is definatly a way to do what you want, however, a few more of the specifics are needed to be able to actually determine how to do what you want.

 

1. Is the Date/Time column a JMP datetime value, or is it a character string?  JMP datetime column allow one to use one of a large number of formats, including ones that display both the date and time in the same column.

2. If it is a character string, and not a JMP datetime value, what is the format of the data?   (i.e. 21JUN2017 11:15:22, 01/05/1998 12:15AM, etc.)

3. You state that you want the date and time in a new column.  Can you show what you want it to look like? 

4. Since the generation of a formula for a new column is available in a point and click formula generator, you should be really moving towards teaching yourself how to do things such as this.  Great documentation is availabe on this at:

     Help==>Books==>Using JMP==>Formula Editor

Jim
spirotodd
Level II

Re: Creating and filling a new column with a formula

The Date/Time column has the format: y/m/d h:m:s. It displays as "2017/04/10 7:53:35.935 AM" 

 

I would like to have a column titled 'Date' that has the same date format and a column titled 'Time' that displays in 24 hour time.

 

Thank you for the book reference. I am able to generate new columns with formulas by hand, it is JSL I am unfamiliar with. Do you know of a good reference for learning JSL?

 

 

txnelson
Super User

Re: Creating and filling a new column with a formula

Attached is a sample data table that has a column called "date and time" which contains a JMP numeric DateTime value.  I then created 2 new columns, "date" and "time".  Each of them contain a formats that strips out just the date part and just the time part.

The Column Info for the columns is what is used to format the columns to display the numeric values in a DateTime, Date or Time format.

As far as resources on learning JSL, I always suggest reading the Scripting Guide

     Help==>Books==>Scripting Guide

There are also many script examples in

     Help==>Sample Data==>Open the Sample Scripts Directory

The definative reference material is at:

     Help==>Scripting Index

Jim