Choose Language Hide Translation Bar
Highlighted
davyvy
Level I

How to select individual cell based on condition?

How to select individual cell instead of entire rows?

In table below, I need to select the two -99 cells under Value1 and Value2 column, and delete them. Can someone help? When I used select where, the entire row is selected.

test1Value1test2Value2
2531
354-99
4-995443
-8876234
779-763
506545

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
jerry_cooper
Staff (Retired)

Re: How to select individual cell based on condition?

Just in case you were looking for a non-scripting approach, you could use search and replace (Ctrl+F), or you could use Column Properties and set -99 as a missing value code. If you use the search option, be sure to leave the Replace With box empty (i.e no space).

View solution in original post

4 REPLIES 4
Highlighted
txnelson
Super User

Re: How to select individual cell based on condition?

Selecting a single cell, in the context of "Select Where" isn't really available.  But addressing a single cell can be done and then the cell value can be changed, or the cell color can be changed.  Here is an example of how to do this:

Names Default to Here(1);

dt=current data table();

dt:Value 2 << color cells("Red", dt<<get rows where(dt:Value 2 == -99));

Jim
Highlighted
Phil_Brown
Super User

Re: How to select individual cell based on condition?

davyvy​,

One approach is to simply clear the value of the cell and replace it with missing value (essentially same as delete). So..


:Value1 << Set Each Value( If( Value1[ ] == -99, ., Value1[ ] ) );

:Value2 << Set Each Value( If( Value2[ ] == -99, ., Value2[ ] ) );


I've found that Set Each Value is quite fast. I ran a  test on a 5 column, 6.6M row table and each of the operations above completed in ~2s.

PDB
Highlighted
jerry_cooper
Staff (Retired)

Re: How to select individual cell based on condition?

Just in case you were looking for a non-scripting approach, you could use search and replace (Ctrl+F), or you could use Column Properties and set -99 as a missing value code. If you use the search option, be sure to leave the Replace With box empty (i.e no space).

View solution in original post

Highlighted
ron_horne
Super User

Re: How to select individual cell based on condition?

alternatively, you can use the recode option to change the -99 to missing values or whatever value you want. just right click the column from the column list on the left and select recode. the rest is self explanatory.

Article Labels

    There are no labels assigned to this post.