cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
yuedeng1015
Level I

JSL to summarize delta ranges in different column

Hello, I have a data table that had 6 repeat test data set. I need to summarize index from each test but not sure how to do so:

 

yuedeng1015_1-1609288386746.png

For each test, I need to summarize the time range (column 1) in between -0.5 to 0.5. For example for test 1, time between -0.5 to 0.5 is 12.

Is this something doable in summary table or formula? What would be the right script for this?

 

Any help is highly appreciated. Thank you!

 

2 REPLIES 2
txnelson
Super User

Re: JSL to summarize delta ranges in different column

Here is a slow, but easy way to calculate the time ranges

Names Default To Here( 1 );

// Create a sample data table
dt = New Table( "example",
	Add Rows( 100 ),
	New Column( "Time",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Selected,
		Set Values(
			[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
			37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70,
			71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]
		)
	),
	New Column( "Test 1",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values(
			[-0.979095261543989, -0.896742071490735, -0.889349037315697, -0.87244444526732, -0.870235625654459, -0.850023841951042,
			-0.825814047828317, -0.810987726319581, -0.793238427489996, -0.779934050049633, -0.77751679206267, -0.776956817135215, -0.732764133252204,
			-0.727529654279351, -0.692787360865623, -0.623450060840696, -0.586516071576625, -0.510782579425722, -0.49689367832616, -0.486707606352866,
			-0.484344476368278, -0.481799592263997, -0.459313589613885, -0.438752442132682, -0.437831206247211, -0.426413411740214,
			-0.389292314648628, -0.371015771757811, -0.321171685587615, -0.303731133695692, -0.299223347101361, -0.2955910153687, -0.295171628706157,
			-0.287196798250079, -0.266310835722834, -0.245707446709275, -0.222742850426585, -0.221946340985596, -0.211779735982418, -0.19290339993313,
			-0.161657535471022, -0.151063158176839, -0.146211542189121, -0.107925229240209, -0.102463736198843, -0.0942716896533967,
			-0.0625418536365033, -0.0593226337805391, -0.0551141467876733, -0.00844738306477677, 0.0499552823603151, 0.0548975612036882,
			0.0620410777628419, 0.0825509736314414, 0.105214339215308, 0.112333746626973, 0.115725796669721, 0.124213374219835, 0.132224208675325,
			0.138283293228596, 0.139169875532388, 0.143728867638856, 0.158808295149356, 0.175987505353987, 0.18856290075928, 0.189136556815356,
			0.195915278047323, 0.20057629654184, 0.211810931097716, 0.237786473706364, 0.287937940098345, 0.289922350086272, 0.310370716266334,
			0.312026916537434, 0.364328261930495, 0.372934360988438, 0.373607663437724, 0.387245952617377, 0.394884287845343, 0.41628627711907,
			0.416538912337273, 0.42591700842604, 0.44973706221208, 0.499667901545763, 0.527553438674658, 0.536425462923944, 0.547215102706104,
			0.555829521734267, 0.573288558982313, 0.57670431304723, 0.578423537779599, 0.581196432001889, 0.591011966113001, 0.740358236711472,
			0.750868909992277, 0.803038085345179, 0.805981820914894, 0.878294591326266, 0.937882805243134, 0.945792773272842]
		)
	),
	New Column( "Test 2",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values(
			[-0.985294728074223, -0.982352695427835, -0.94259925885126, -0.885286076460034, -0.882707166019827, -0.87060605129227, -0.860511588864029,
			-0.833731018472463, -0.78135885996744, -0.736944859381765, -0.729077083524317, -0.718071651179344, -0.697938580531627, -0.675371109507978,
			-0.652842328883708, -0.65161001868546, -0.617828567977995, -0.610566718038172, -0.590526529122144, -0.516985419671983, -0.512218405958265,
			-0.494330945424736, -0.492088324390352, -0.480665533337742, -0.476449086796492, -0.474025260657072, -0.472780757583678,
			-0.437782075721771, -0.416823129635304, -0.404738629702479, -0.399891371373087, -0.376697348896414, -0.368973867502064,
			-0.365583977196366, -0.334596856031567, -0.325426132883877, -0.304021639749408, -0.261881055310369, -0.226391016039997, -0.22058630688116,
			-0.21474217902869, -0.206998155452311, -0.193417022470385, -0.184500204399228, -0.180855971295387, -0.126933943014592, -0.106519164517522,
			-0.0815543159842492, -0.0743878353387119, -0.0573135549202562, -0.0361455939710141, -0.0211831559427084, -0.0028942064382137,
			0.019942447543144, 0.0337544307112692, 0.0473832655698059, 0.0551646249368784, 0.0671577369794247, 0.0765933836810289, 0.108595847152173,
			0.110952034592628, 0.144529090728611, 0.159022842999547, 0.194648185744881, 0.20542282005772, 0.234908728394657, 0.255376940127462,
			0.260558616369962, 0.264570861589163, 0.288875991012901, 0.288894841913134, 0.388773819897324, 0.428409767337143, 0.435227599926293,
			0.454370931722224, 0.517001557629555, 0.539542051032185, 0.547272523399442, 0.553526939358562, 0.571997350547463, 0.580522693227976,
			0.581790030933916, 0.677938124164939, 0.705488494597375, 0.708717150148004, 0.711434475146234, 0.721891332417726, 0.732670046854764,
			0.739695797208696, 0.756741309072822, 0.76525106607005, 0.842888320796191, 0.88402612414211, 0.886491112876683, 0.896574725862592,
			0.913369336631149, 0.914040161296725, 0.935554534196853, 0.961838115006685, 0.966545533854514]
		)
	)
);


// Calculate the time range for each column
timeRangeList = {};

For( i = 2, i <= N Cols( dt ), i++,
	range = Min( dt << get rows where( As Column( i ) > .5 ) ) - Min( dt << get rows where( As Column( i ) > -.5 ) );
	Insert Into( timeRangeList, range );
);

// Display the range values to the log
Show( timeRangeList );

 

Jim
yuedeng1015
Level I

Re: JSL to summarize delta ranges in different column

Thank you very much Jim!