cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar

how to exclude rows from Col Rank formula in JSL?

I'm trying to run a Col Rank formula on a "BLOCKERASECYCLE" column and then output the result to a new column "TEMPCOLUMN"

However it runs Col Rank even on rows that I hide and exclude (rows are not "VERSION1").

How can I get Col Rank to skip rows that I hide and exclude (non "VERSION1" rows)?

BLOCKERASECYCLE_COL = Column("BLOCKERASECYCLE");

foundrows = dt << Get Rows Where(:PART_VERSION=="VERSION1");

dt<<Select Rows(foundrows);

dt<<Invert Row Selection;

dt<<Exclude;//Exclude non-VERSION1 rows

dt<<Hide;//Hide non-VERSION1 rows

dt<<Invert Row Selection;

dt<<New Column("TEMPCOLUMN", Numeric, Formula(Col Rank(BLOCKERASECYCLE_COL)));

1 ACCEPTED SOLUTION

Accepted Solutions

Re: how to exclude rows from Col Rank formula in JSL?

Hi, Steve.

The following formula will calculate the rank for only un-excluded rows:


Col Rank(If(Excluded(), ., :height))


You can verify that the formula is correct by running a Distribution on your BLOCKERASECYCLE column and then save the ranks (red triangle > Save > Ranks).  This will generate a new column that contains the ranks for un-excluded rows, which you can compare to the formula column.  Of course, you could just use the Distribution platform to generate the rank column in the first place, as well. 

Hope that helps.

Wendy

Wendy

View solution in original post

3 REPLIES 3
pmroz
Super User

Re: how to exclude rows from Col Rank formula in JSL?

Try this.  A bit klugy but it works

dt = current data table();

foundrows = dt << Get Rows Where(:PART_VERSION=="VERSION1");

nv1 = nrows(foundrows);

dt << New Column( "TEMPCOLUMN", Numeric,

Formula( if (:PART_VERSION != "VERSION1", Col Rank( :BLOCKERASECYCLE ) - nv1 ) ) );

Re: how to exclude rows from Col Rank formula in JSL?

Hi, Steve.

The following formula will calculate the rank for only un-excluded rows:


Col Rank(If(Excluded(), ., :height))


You can verify that the formula is correct by running a Distribution on your BLOCKERASECYCLE column and then save the ranks (red triangle > Save > Ranks).  This will generate a new column that contains the ranks for un-excluded rows, which you can compare to the formula column.  Of course, you could just use the Distribution platform to generate the rank column in the first place, as well. 

Hope that helps.

Wendy

Wendy

Re: how to exclude rows from Col Rank formula in JSL?

Thanks, replacing the last statement with this new one is able to ignore the excluded rows:

dt<<New Column("TEMPCOLUMN", Numeric, Formula(Col Rank(If(Excluded(), ., BLOCKERASECYCLE_COL))));