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

Settings value of column based on selected column in a summary table

Hi experts.

 

I have a linked summary table, in which i select rows, based on a criteria.

In my main table, I now need to set a specific value in a column, for the selected rows.

 

I have made a basic table with the following:

Sample   error

s1            0
s1            0
s1            0
s2            0
s2            0
s2            0

 

I have some very simplified code as an example:

 

dt = current data table();

dt_sum = dt << Summary(
Group( :sample),
Freq( "None" ),
Weight( "None" )
);

dt_sum << select where (:sample == "s1");
r = dt << get selected rows;

close(dt_sum, nosave);

column(dt, "error")[r] = 1;

 

The code runs, if the dt_sum is closed. In my code however, this is not possible, as it is needed later.

 

I get the following error, if dt_sum is not closed

"Cannot set value for the column 'error' because the row number (-1) is not valid.{1}"

 

Further more, the error value for line 1 and 4 is changed to 1, but not the rest.

 

 

Can any of you explain me why this is not working, or help me with a possible workaround?

 

Thanks in advance, Anders

 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Settings value of column based on selected column in a summary table

1.  I think you should submit the issue to JMP Support.  It appears that eventhough you are directly pointing to the "dt" data table, it is still looking to the "dt_sum" data table and updating there.

2. Here is a work around that allows the code to work

dt = current data table();
dt_sum = dt << Summary(
Group( :sample),
Freq( "None" ),
Weight( "None" )
);
dt_sum << select where (:sample == "s1");
r = dt << get selected rows;
//close(dt_sum, nosave);
current data table(dt);
column(dt, "error")[r] = 1;
Jim

View solution in original post

2 REPLIES 2
txnelson
Super User

Re: Settings value of column based on selected column in a summary table

1.  I think you should submit the issue to JMP Support.  It appears that eventhough you are directly pointing to the "dt" data table, it is still looking to the "dt_sum" data table and updating there.

2. Here is a work around that allows the code to work

dt = current data table();
dt_sum = dt << Summary(
Group( :sample),
Freq( "None" ),
Weight( "None" )
);
dt_sum << select where (:sample == "s1");
r = dt << get selected rows;
//close(dt_sum, nosave);
current data table(dt);
column(dt, "error")[r] = 1;
Jim
AWMN
Level II

Re: Settings value of column based on selected column in a summary table

Thanks, that does it :)