Subscribe Bookmark RSS Feed

Sum specific columns in each row

DataMojo

Occasional Contributor

Joined:

Feb 10, 2017

I would like to sum specific columns in each row.

I can find the maximum value in each row using the below :

location =  Loc Max( dt[r, {a,b,c} );

 

but cannot use the sum 

Total = Sum( dt[r, {a,b,c} );

2 ACCEPTED SOLUTIONS

Accepted Solutions
DataMojo

Occasional Contributor

Joined:

Feb 10, 2017

Solution

Worked around, by hard coding the column names :

For Each Row(
r = Row();

Column = (:Name( "COL1" )) / (:Name( "COL23" ) + :Name( "COL24" ) + :Name( "COL25" )) ;

);

Craige_Hales

Staff

Joined:

Mar 21, 2013

Solution

Maybe a missing ] ?  This works for me.

dt=open("$sample_data/big class.jmp");
sum(dt[3,{height,weight,age}]);

Maybe the r variable is uninitialized. Use show(r); to see what it is. Check the JMP log window for messages. 

Not sure why you would add these togetherNot sure why you would add these together

 

Craige
2 REPLIES
DataMojo

Occasional Contributor

Joined:

Feb 10, 2017

Solution

Worked around, by hard coding the column names :

For Each Row(
r = Row();

Column = (:Name( "COL1" )) / (:Name( "COL23" ) + :Name( "COL24" ) + :Name( "COL25" )) ;

);

Craige_Hales

Staff

Joined:

Mar 21, 2013

Solution

Maybe a missing ] ?  This works for me.

dt=open("$sample_data/big class.jmp");
sum(dt[3,{height,weight,age}]);

Maybe the r variable is uninitialized. Use show(r); to see what it is. Check the JMP log window for messages. 

Not sure why you would add these togetherNot sure why you would add these together

 

Craige