Choose Language Hide Translation Bar
Highlighted
lwx228
Community Trekker

How many ways to write JSL code for sum of the first five rows of a column in a table?

HLPE
For example, take Big Class. JMP as an example. First, the "age" of column 2 is sorted downward, and then the sum of the values of the first five rows of column 2 is calculated.How many ways can this be written in JSL code?Thank you very much!


The following code is incorrect:

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
col = Column( dt, 2 );
dt << Select Where( col[] > 14 & row()<=5 );
n = Col Sum(col[],Selected());

0 Kudos
1 ACCEPTED SOLUTION

Accepted Solutions
Craige_Hales
Staff (Retired)

Re: How many ways to write JSL code for sum of the first five rows of a column in a table?

try something like

sum(dt[ 1::5, 2 ] ) or sum(dt[1::5, "age" ] )

https://community.jmp.com/t5/Uncharted/Data-table-subscripting/ba-p/21013

Craige

View solution in original post

2 REPLIES 2
Craige_Hales
Staff (Retired)

Re: How many ways to write JSL code for sum of the first five rows of a column in a table?

try something like

sum(dt[ 1::5, 2 ] ) or sum(dt[1::5, "age" ] )

https://community.jmp.com/t5/Uncharted/Data-table-subscripting/ba-p/21013

Craige

View solution in original post

lwx228
Community Trekker

Re: How many ways to write JSL code for sum of the first five rows of a column in a table?

Thank you very much! I have too little.
0 Kudos