Subscribe Bookmark RSS Feed

Creating and filling a new column with a formula

spirotodd

New Contributor

Joined:

Sep 25, 2017

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

Joined:

Jun 22, 2012

Solution

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
5 REPLIES
txnelson

Super User

Joined:

Jun 22, 2012

Solution

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

New Contributor

Joined:

Sep 25, 2017

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

Joined:

Jun 22, 2012

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

New Contributor

Joined:

Sep 25, 2017

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

Joined:

Jun 22, 2012

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