cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Submit your abstract to the call for content for Discovery Summit Americas by April 23. Selected abstracts will be presented at Discovery Summit, Oct. 21- 24.
Discovery is online this week, April 16 and 18. Join us for these exciting interactive sessions.
Choose Language Hide Translation Bar
agonzales2021
Level III

Count(Rows Selected) & quickly summarize categories (under one or two columns) of rows selected. [1]

I have two columns selected once a graph launches (those categorical columns are on the X axis). As a user selects different points over the graph, specific rows are selected (like in normal graphing).

 

I'm looking for a way to do the following things:

1) Count number of rows selected

2) Identify what category (X coordinate) is selected on the graph (since only one will be selected at a time).

 

I'm amazed at how much difficulty I'm having with such a simple thing. I keep looking at the scripting index but to no avail.

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Count(Rows Selected) & quickly summarize categories (under one or two columns) of rows selec

Here is a simple script that shows one way to handle the questions you ask

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\big class.jmp" );

dt << bivariate( x( :height ), y( :weight ) );

dt << select rows( {2, 4, 6} );

Show( N Rows( dt << get selected rows ) );
Show( dt:height[(dt << get selected rows)[1]] );
Jim

View solution in original post

5 REPLIES 5
txnelson
Super User

Re: Count(Rows Selected) & quickly summarize categories (under one or two columns) of rows selec

Here is a simple script that shows one way to handle the questions you ask

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\big class.jmp" );

dt << bivariate( x( :height ), y( :weight ) );

dt << select rows( {2, 4, 6} );

Show( N Rows( dt << get selected rows ) );
Show( dt:height[(dt << get selected rows)[1]] );
Jim
agonzales2021
Level III

Re: Count(Rows Selected) & quickly summarize categories (under one or two columns) of rows selec

Always coming to my aid! Thank you so much Jim. This is perfect and exactly what I needed. Reading a little more on this to see what else I can do :D

Re: Count(Rows Selected) & quickly summarize categories (under one or two columns) of rows selec

See Help > Scripting Index > Objects > Data Table > Make Row State Handler

agonzales2021
Level III

Re: Count(Rows Selected) & quickly summarize categories (under one or two columns) of rows selec

And thank YOU for this! 

Reading about the Row state handler too as I'm pretty sure I can use this in another similar issue I was having :D You guys rock!

agonzales2021
Level III

Re: Count(Rows Selected) & quickly summarize categories (under one or two columns) of rows selec

I do have one last followup question though based on the solution you gave me.

 

In VBA for example there is a function 'countif' where I can specify for a range of cells (N Rows in my case) and count the occurrences of a given item in that column.

I can think of many ways to do this but most of them involve summaries. So say I use that second command you gave me Jim to figure out what element of X is selected. How can I then count the total occurrences of this in the table? (I know that's redundant but like I said there are two x variables and they are linked: months and weeks, so if I select a month, several weeks get selected, etc).


Could I use something like 

r = Current Data Table() << get rows where( :height == 60 );

:name[r[Contains( :sex, :sex )]]; followed by the count you suggested?