cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Register for our Discovery Summit 2024 conference, Oct. 21-24, where you’ll learn, connect, and be inspired.
Choose Language Hide Translation Bar
VO
VO
Level I

Scripting, specifically to automate graphing of data for the last 30 days

Novice on scripting, using JMP 16, looking for help to graph, the last 30 days of data - from today's date.

Currently using local data filter and selecting points, but there must be a better way to add this to the script, please advise.

Thanks!

Local Data Filter(
		Auto clear( 1 ),
		Add Filter(
			columns( :Recipe, :Date ),
			Where(
				:Date == {"220509", "220511", "220513", "220516", "220517", "220524",
				"220526", "220531", "220602", "220608", "220613", "220614", "220616",
				"220620", "220621", "220713", "220718", "220719"}
			),
			Display( :Recipe, N Items( 15 ) ),
			Display( :Date, N Items( 15 ), Find( Set Text( "" ) ) )
		)
1 ACCEPTED SOLUTION

Accepted Solutions

Re: Scripting, specifically to automate graphing of data for the last 30 days

(Apologies to @txnelson because I left the discussion window open from earlier and did not see his reply.)

 

Let's start over. I would add a data column for the converted date value (numeric) and leave the original date value (character) as it is. So the data table now might look like this:

 

table.PNG

 

The New Date column is numeric values formatted as dates. See this dialog to understand the attributes of the new data column:

 

dialog.PNG

 

A simple formula deconstructs the original character string to build a proper JMP time value:

 

formula.PNG

 

Now use New Date for your filter instead of Date. It doesn't matter about whether the column is locked.

View solution in original post

8 REPLIES 8
txnelson
Super User

Re: Scripting, specifically to automate graphing of data for the last 30 days

To start, I suggest that you convert your Date column to a JMP Date/Time value.  The current Date column is just a character column, which follows Alphanumeric rules, not Date/Time rules. Here is a simple script that will create a new column called JMPDate, whch  will be transformed from your Date column

Names Default To Here( 1 );
dt = Current Data Table();

dt << New Column( "JMPDate",
	set each value(
		Date MDY(
			Num( Substr( :date, 3, 2 ) ),
			Num( Right( :date, 2 ) ), 
			Num( "20" || Left( :date, 2 ) )
		)
	),
	Format( "m/d/y" )
);

Once it is a JMP Date/Time column, you can do such things as

dt << select where(:JMPDate > 05/31/2022);

or

dt << select where(:JMPDate > Today() - inDays(180));
Jim
VO
VO
Level I

Re: Scripting, specifically to automate graphing of data for the last 30 days

Thanks for the help "txnelson," but not an easy fix, since it appears that perhaps I worded the question wrong or incomplete.

 

The Date column is being created / sourced from the name column, which is the output file from the tool, that encompasses a description of several characteristics specific to the run, in this manner: "Date_tool Id_ recipe_ material_position_run#."  That said, since the source of this original column is set to Character, the newly created "Date" column (done for ease of plotting) will not accept the change from Character to Date. Any idea why? Or better suggestion for the Date column formula?

Item( 1, :Source, "_" )
txnelson
Super User

Re: Scripting, specifically to automate graphing of data for the last 30 days

Has a Lock been placed on the Date column, or is the Date column being used to set values in other columns through formulas?

 

The new column, JMPDate should be being created correctly.  You can use that column for the selection, etc.

Jim
VO
VO
Level I

Re: Scripting, specifically to automate graphing of data for the last 30 days

I think that is the problem, the column is locked automatically, so it does not take the Date change. Also, no other columns are dependent on this Date column. 

 

Attempted to recreate a new column, with the same Formula, and as soon as the formula is applied it locks that column as well. 

txnelson
Super User

Re: Scripting, specifically to automate graphing of data for the last 30 days

Click on the red triangle in the Table Panel and unselect the Lock Table setting

Jim
VO
VO
Level I

Re: Scripting, specifically to automate graphing of data for the last 30 days

The "Lock Data Table" was not selected. I tried unlocking the column with and without the selection, and neither worked.

txnelson
Super User

Re: Scripting, specifically to automate graphing of data for the last 30 days

How is the table created?  The platform that is used to create the table, many times has an option to link/lock the new table.  If so, change the linking in the table creation.

Jim

Re: Scripting, specifically to automate graphing of data for the last 30 days

(Apologies to @txnelson because I left the discussion window open from earlier and did not see his reply.)

 

Let's start over. I would add a data column for the converted date value (numeric) and leave the original date value (character) as it is. So the data table now might look like this:

 

table.PNG

 

The New Date column is numeric values formatted as dates. See this dialog to understand the attributes of the new data column:

 

dialog.PNG

 

A simple formula deconstructs the original character string to build a proper JMP time value:

 

formula.PNG

 

Now use New Date for your filter instead of Date. It doesn't matter about whether the column is locked.