Subscribe Bookmark RSS Feed

Data Summary question

BrianK

New Contributor

Joined:

Jan 19, 2017

Hi guys,

 

Attached is an example of a data set I'm working with. Its 1 weeks worth of data from 2 sensors. I'm trying to write a JSL script to take this data and by sensor average the first 24 hours of data, the last 6 hours of data, and substract the two, finally summarising the difference in a summary table, by sensor. Does anyone have any ideas?

2 REPLIES
txnelson

Super User

Joined:

Jun 22, 2012

try this

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

dt << New Column( "Group",
	Character,
	formula(
		If(
			:Timestamp < Col Minimum( :Timestamp, :Sensor Number ) + 24 * 60 * 60, "First",
			:Timestamp > Col Maximum( :Timestamp, :Sensor Number ) - 6 * 60 * 60, "Last"
		)
	)
);

dtsumm = dt << Summary(
	Group( :Sensor Number ),
	Mean( :DataValue ),
	Subgroup( :Group ),
	Freq( "None" ),
	Weight( "None" ),
	statistics column name format( "column" ),
	Link to original data table( 0 )
);

dtsumm << New Column( "Delta", formula( :name( "DataValue, First" ) - :name( "DataValue, Last" ) ) );
Jim
ian_jmp

Staff

Joined:

Jun 23, 2011

Very neat!