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

adding two columns and doing sum in JSL


i have an excel sheet with the following rows and columns:

NumbersRed BlueBlackGreen
70061012
70091234
70121456
70151678
701818910
70211101112
70241121314
70271141516
70301161718
70331181920
70361202122
70391222324

now i need to add two columns namely red+blue and black+green  and count the total of red+blue for each number and place in the resultant column..and same with the second column too..my result should be

NumbersRed BlueBlackGreenred+blueblack+green
7006101213
7009123437
70121456511
70151678715
701818910919
702111011121123
702411213141327
702711415161531
703011617181735
703311819201939
703612021222143
7039122232423

47

can some one help me with the code?

1 ACCEPTED SOLUTION

Accepted Solutions
ms
Super User (Alumni) ms
Super User (Alumni)

Re: adding two columns and doing sum in JSL

Assuming you know how to import (or just paste) your table into JMP, it is pretty straight-forward. The example below illustrates two approaches 1) static columns and 2) column formulas. The latter will update the sum if values are changed, the former will not.

//Make example table

dt=New Table( "Colors",

  Add Rows( 3 ),

  New Column( "Numbers",

  Numeric,

  Continuous,

  Format( "Best", 4 ),

  Set Selected,

  Set Values( [7006, 7009, 7012] )

  ),

  New Column( "Red",

  Numeric,

  Continuous,

  Format( "Best", 12 ),

  Set Selected,

  Set Values( [1, 1, 1] )

  ),

  New Column( "Blue",

  Numeric,

  Continuous,

  Format( "Best", 12 ),

  Set Selected,

  Set Values( [0, 2, 4] )

  ),

  New Column( "Black",

  Numeric,

  Continuous,

  Format( "Best", 12 ),

  Set Selected,

  Set Values( [1, 3, 5] )

  ),

  New Column( "Green",

  Numeric,

  Continuous,

  Format( "Best", 12 ),

  Set Selected,

  Set Values( [2, 4, 6] )

  )

);

//Alternative 1: static columns

dt<<new column("Red+Blue", continious);

dt<<new column("Black+Green", continious);

for each row(:Name("Red+Blue")=:Red+:Blue);

for each row(:Name("Black+Green")=:Black+:Green);

//Alternative 2: Column formulas

dt<<new column("Red+Blue2", continious, Formula(:Red+:Blue));

dt<<new column("Black+Green2", continious, Formula(:Black+:Green));

View solution in original post

1 REPLY 1
ms
Super User (Alumni) ms
Super User (Alumni)

Re: adding two columns and doing sum in JSL

Assuming you know how to import (or just paste) your table into JMP, it is pretty straight-forward. The example below illustrates two approaches 1) static columns and 2) column formulas. The latter will update the sum if values are changed, the former will not.

//Make example table

dt=New Table( "Colors",

  Add Rows( 3 ),

  New Column( "Numbers",

  Numeric,

  Continuous,

  Format( "Best", 4 ),

  Set Selected,

  Set Values( [7006, 7009, 7012] )

  ),

  New Column( "Red",

  Numeric,

  Continuous,

  Format( "Best", 12 ),

  Set Selected,

  Set Values( [1, 1, 1] )

  ),

  New Column( "Blue",

  Numeric,

  Continuous,

  Format( "Best", 12 ),

  Set Selected,

  Set Values( [0, 2, 4] )

  ),

  New Column( "Black",

  Numeric,

  Continuous,

  Format( "Best", 12 ),

  Set Selected,

  Set Values( [1, 3, 5] )

  ),

  New Column( "Green",

  Numeric,

  Continuous,

  Format( "Best", 12 ),

  Set Selected,

  Set Values( [2, 4, 6] )

  )

);

//Alternative 1: static columns

dt<<new column("Red+Blue", continious);

dt<<new column("Black+Green", continious);

for each row(:Name("Red+Blue")=:Red+:Blue);

for each row(:Name("Black+Green")=:Black+:Green);

//Alternative 2: Column formulas

dt<<new column("Red+Blue2", continious, Formula(:Red+:Blue));

dt<<new column("Black+Green2", continious, Formula(:Black+:Green));