cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
nter
Level II

Unexpected behavior when tagging selected data and then deleting other rows

When you try to permanently tag some currently selected data and then delete rows above the data, the tag moves to a different data entry.

 

For example, select row five, right click a column and select "new formula column" -> "row" -> "selected"

this makes a new column "selected" that is all zeros except for row five, which is marked one.  Very helpful!

 

however, if you then delete row #2 for some reason, row five is still marked "1" in column "selected"!

I would have expected it to now be only row 4 that is marked selected, because that's the entry that I tagged.

 

Is that intended?  I bet most people expect to be able to delete rows without having their remaining entries receive different values.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Unexpected behavior when tagging selected data and then deleting other rows

Hi,

 

Inspecting the formula will show us what is happening here. Below, I've made a table and done the same thing you did: I selected row 5 and then installed a 1-click "selection" column on row 5. Note this currently corresponds to the row whose value is 28 in col1.

 

brady_brady_0-1625605351093.png

 

 

Upon deleting row 2, just as you mention--row 5 still has a 1, but this is not the row whose value is 28 in col1.

 

brady_brady_1-1625605466005.png

 

Double-clicking the "+" to the right of the Selected column in the Cols pane, we see an image telling us the formula contains a 15x1 matrix, indexed by the row() function.

brady_brady_2-1625605560335.png

 

Double-click this image to see the formula itself:

brady_brady_3-1625605610980.png

 

This formula is always going to place a "1" in the 5th row, as the 1 is hard-coded into the matrix. In fact, change some of the zeros to ones and you'll see that now, other rows are also set to "1".

 

It does not matter that our table had 15 rows when we started and now has only 14 rows... any rows in the matrix with a "1" will receive a "1" in the table, as long as the row exists.

 

Why would someone use this? Perhaps for easily selecting certain rows later after multiple resortings... for example, let's say we set the top 50 (or 500) rows to 1 using this method. We can now sort by any column, then subset easily by right-clicking on a 1 in this "selected" column, choosing "select matching cells", then selecting table > subset and hitting return. I can repeat this over and over to get "top 50" (or top 500) subsets according to various criteria, without using another formula, and without scrolling to select the first 50 rows.

 

That said, this is an unusual use case. I had to dream it up... I've never actually done this.

 

If you want to prevent this behavior, there are a couple of easy ways:

1) Proceed as you have, then remove the formula. The easiest way to do this is to double-click the plus sign, hit the delete key, and click "OK".

 

2) You could instead create the column by selecting, from the main menu, Rows > Row Selection > Name Selection in Column, which does NOT result in a formula.

 

3) Finally, if you DO want 1s to appear dynamically for any selected rows, do this:

1) Add a new column

2) Right-click on the column header and select Formula...

3) Enter this formula:

 

Selected ( Row State ( ) )

 

4) Click "OK".

 

You've now created a column whose value is 1 whenever a row is selected, and is 0 otherwise. Click around, selecting different rows and you'll notice that the values update to reflect the current selection. This is one of my favorite data table tricks. There are some ideas on how this might be useful here: https://community.jmp.com/t5/JMP-On-Air/Special-Formula-Columns/ta-p/257371

 

 

Cheers,

Brady

 

 

 

 

 

View solution in original post

2 REPLIES 2

Re: Unexpected behavior when tagging selected data and then deleting other rows

Hi,

 

Inspecting the formula will show us what is happening here. Below, I've made a table and done the same thing you did: I selected row 5 and then installed a 1-click "selection" column on row 5. Note this currently corresponds to the row whose value is 28 in col1.

 

brady_brady_0-1625605351093.png

 

 

Upon deleting row 2, just as you mention--row 5 still has a 1, but this is not the row whose value is 28 in col1.

 

brady_brady_1-1625605466005.png

 

Double-clicking the "+" to the right of the Selected column in the Cols pane, we see an image telling us the formula contains a 15x1 matrix, indexed by the row() function.

brady_brady_2-1625605560335.png

 

Double-click this image to see the formula itself:

brady_brady_3-1625605610980.png

 

This formula is always going to place a "1" in the 5th row, as the 1 is hard-coded into the matrix. In fact, change some of the zeros to ones and you'll see that now, other rows are also set to "1".

 

It does not matter that our table had 15 rows when we started and now has only 14 rows... any rows in the matrix with a "1" will receive a "1" in the table, as long as the row exists.

 

Why would someone use this? Perhaps for easily selecting certain rows later after multiple resortings... for example, let's say we set the top 50 (or 500) rows to 1 using this method. We can now sort by any column, then subset easily by right-clicking on a 1 in this "selected" column, choosing "select matching cells", then selecting table > subset and hitting return. I can repeat this over and over to get "top 50" (or top 500) subsets according to various criteria, without using another formula, and without scrolling to select the first 50 rows.

 

That said, this is an unusual use case. I had to dream it up... I've never actually done this.

 

If you want to prevent this behavior, there are a couple of easy ways:

1) Proceed as you have, then remove the formula. The easiest way to do this is to double-click the plus sign, hit the delete key, and click "OK".

 

2) You could instead create the column by selecting, from the main menu, Rows > Row Selection > Name Selection in Column, which does NOT result in a formula.

 

3) Finally, if you DO want 1s to appear dynamically for any selected rows, do this:

1) Add a new column

2) Right-click on the column header and select Formula...

3) Enter this formula:

 

Selected ( Row State ( ) )

 

4) Click "OK".

 

You've now created a column whose value is 1 whenever a row is selected, and is 0 otherwise. Click around, selecting different rows and you'll notice that the values update to reflect the current selection. This is one of my favorite data table tricks. There are some ideas on how this might be useful here: https://community.jmp.com/t5/JMP-On-Air/Special-Formula-Columns/ta-p/257371

 

 

Cheers,

Brady

 

 

 

 

 

nter
Level II

Re: Unexpected behavior when tagging selected data and then deleting other rows

Thanks Brady,

Good to see there is a different menu option to produce the version of a selection flag I was looking for.

Also I wasn't thinking about a dynamic flag, but that's a cool trick - thanks for sharing.