How do I get a JSL script to Sum cells based of other cells.Hi All,
I've gotten stuck trying to write a script that will Sum cells based on 2 other cells within the same row.
Im able to select the correct rows with
dt << row selection (Select where (:Column 3== CurrentWrkWk & :Column 1== "TIM703"));
Final answer I expect is
The sum should be 3.913.
Ive been reading the scripting index but am lost
Names Default To Here( 1 );
Clear Globals();
dt = current data table();
CurrentWrkWk = 202450;
a1 == dt << row selection (Select where (:Column 3== CurrentWrkWk & :Column 1== "TIM703"));
Var1 =Col Cumulative Sum(:StateHour, a1);
show(Var1);
>
JMP version 17
Basic Data Analysis and ModelingRe: How do I get a JSL script to Sum cells based of other cells.I think this might do what you want
Var1 = Col Cumulative Sum(
If( :Column 3 == CurrentWrkWk & :Column 1 == "TIM703",
:StateHour,
.
),
a1
);
Re: How do I get a JSL script to Sum cells based of other cells.For sum you can also use data table subscripting
Names Default To Here( 1 );
dt = Open("$SAMPLE_DATA/Big Class.jmp");
age_of_interest = 12;
sex_of_interest = "F";
rows_of_interest = dt << Get Rows Where(:age == age_of_interest & :sex == sex_of_interest);
res = Sum(dt[rows_of_interest, "height"]);
Re: How do I get a JSL script to Sum cells based of other cells.Hi Jthi,
Thank you this has worked