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
Neo
Neo
Level VI

How to get non-empty row values corresponding to chosen labels from columns?

I have incoming data of the form as attached.

I want to get the first first three row values from each column (encircled red) which appear against specific labels (encircled blue).

The following works for Current but not for Voltage (for Voltage I get empty values which I understand why)

Stage = "7";  resCol = "Current"; 
theLSL = Column( dt, resCol )[(dt << get rows where( :TestStage == Stage & :label == "LSL" ))[1]];  show (theLSL);
theUSL = Column( dt, resCol )[(dt << get rows where( :TestStage == Stage & :label == "USL" ))[1]];  show (theUSL);

Neo_0-1700496678454.png

There are other columns in my data table populated similarly for other test test stages/labels. 

When it's too good to be true, it's neither
2 ACCEPTED SOLUTIONS

Accepted Solutions
jthi
Super User

Re: How to get non-empty row values corresponding to chosen labels from columns?

You could add additional check using IsMissing()

... & !IsMissing(Column(dt, resCol)[])

 

-Jarmo

View solution in original post

jthi
Super User

Re: How to get non-empty row values corresponding to chosen labels from columns?

It is one more search condition to your << get rows where

dt << get rows where(:TestStage == Stage & :label == "USL" & !Is Missing(Column(dt, resCol)[]))
-Jarmo

View solution in original post

8 REPLIES 8
jthi
Super User

Re: How to get non-empty row values corresponding to chosen labels from columns?

You could add additional check using IsMissing()

... & !IsMissing(Column(dt, resCol)[])

 

-Jarmo
Neo
Neo
Level VI

Re: How to get non-empty row values corresponding to chosen labels from columns?

@jthi Thanks. 

When it's too good to be true, it's neither
jthi
Super User

Re: How to get non-empty row values corresponding to chosen labels from columns?

It is one more search condition to your << get rows where

dt << get rows where(:TestStage == Stage & :label == "USL" & !Is Missing(Column(dt, resCol)[]))
-Jarmo
txnelson
Super User

Re: How to get non-empty row values corresponding to chosen labels from columns?

The JSL as written only returns the first matching row's value.  While

dt << get rows where( :TestStage == Stage & :label == "LSL" )

returns a matrix of all of the matching rows found,  When the subscript  of [1] is added

(dt << get rows where( :TestStage == Stage & :label == "LSL" ))[1]

it returns the row number of just the first row found, which in your example, returns a missing value.

@jthi Jarmo, suggests adding a further clarification to eliminate missing values, which would change your Get Rows Where() to

(dt << get rows where( :TestStage == Stage & :label == "LSL" & !IsMissing(Column(dt, resCol) ) )[1]

This is a fine solution, if you are just looking for the first non missing value.  However, if your data may contain multiple rows of non missing LSL values, then you may not want the first non missing value found.  You may want to do something like find the Max USL value, or the Mean USL value from all of the non missing rows returned.  You could do something like

theUSL = dt << get rows where( :TestStage == Stage & :label == "LSL" & !Is Missing( Column( dt, resCol ) ) );
USLMat = [];
For Each( {foundRow, index}, theUSL, USLMat = USLMat || Column( dt, resCol )[index] );
theUSL = Mean( USLMat );

 

Jim
miguello
Level VI

Re: How to get non-empty row values corresponding to chosen labels from columns?

I'm trying to do the same thing and in my case 

dt << Get Rows Where(:A == "AAA")

gives a list with one element.

So I have to use

:B[(dt << Get Rows Where(:A == "AAA"))[1]]

 

txnelson
Super User

Re: How to get non-empty row values corresponding to chosen labels from columns?

@miguello, is there a question?

Jim
miguello
Level VI

Re: How to get non-empty row values corresponding to chosen labels from columns?

I guess not. Just would like to understand which behavior is correct and why me and @Neo have it one way, and you have it another?

 

What does it depend on whether it gives matrix or single element list with matrix?

 

 

txnelson
Super User

Re: How to get non-empty row values corresponding to chosen labels from columns?

If you are returning only 1 row from the Get Rows Where() call, then there is no meaningful difference. 

Jim