I need to populate no of unique entries in a new column if Flagged="Yes". When I use Col N Unique formula I get Different count if Flagged="No".
I don't have JMP 19, so no Col N Unique(), but I think this gets you what you want. As Constant() makes the evaluation much faster.
As Constant( Length( Associative Array( :SN[Where( :Flagged == "Yes" )] ) << Get Keys ) )
Current Data Table() << NEW COLUMN("A", Numeric, Formula( Col Sum(If(:Column 2 == "y" & Row() == Col Min(Row(), :Column 1), 1, 0)) ));
I don't use JMP19 so I'm not that familiar with Col N Unique but maybe something like this
Current Data Table() << NEW COLUMN("A", Numeric, Formula( Col Max(If(:Column 2 == "y", Col N Unique(:Column 1, :Column 2), .)) ));
Column 1 is SN and Column 2 is flagged
You are using Flagged == "Yes" as grouping "column" so it will calculate separate unique values for Yes and No.
Any suggestion for how to populate Yes calculation in entire column?
The Col N unique() function is so helpful!It makes many analyses much easier.
I hope,
will work in JMP 19.x.
Looks straight forward- but at the moment this doesn't work - unfortunately, Col N Unique() behaved different to the other col ... aggregations:
[from Tiny Traps in Jmp and JSL ].
txnelson edit: This is not a solution. See @hogi answer below.
Here is how I would do it:
Current Data Table() << New Column( "A", Numeric, Formula( As Constant( theCount = N Rows( Current Data Table() << get rows where( :column 2 == "y" ) ) ); theCount; ) );
JMP 18:
New Column( "unique", Formula( As Constant( Length( Associative Array( :SN[Where( :Flagged == "Yes" )] ) << Get Keys ) ) ) )
JMP19:
dt << New Column( "unique", Formula( Col Max( If( :Column 2 == "y", Col N Unique( :Column 1, :Column 2 ), . ) ) ) );
JMP 19.x:
dt << new column("unique", Formula( Col N Unique(If(:Flagged == "y",:SN, .) ) ));
JMP20?
dt << new column("unique", Formula( Col N Unique(:SN, Where(:Flagged) ) ));
The last one is my favorite - it will facilitate certain types of data analysis a lot!
please vote: Col Median (and others): add "Where" option otherwise we have to wait for v25 ...