<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Script: Data Table Subset With Combo Box Filters in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Script-Data-Table-Subset-With-Combo-Box-Filters/m-p/39534#M23116</link>
    <description>&lt;P&gt;The selection device, pick list vs. slider is based upon what the modeling type for the column is.&amp;nbsp; If you just change the modeling type to "Ordinal" it will make the selection a pick list.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt=open("$SAMPLE_DATA\Movies.jmp");
dt:year &amp;lt;&amp;lt; set modeling type(ordinal);
Current Data Table() &amp;lt;&amp;lt; Data Filter(
	Location( {37, 37} ),
	Add Filter(
		columns( :Type, :Year ),
		Display( :Type, Size( 160, 90 ), List Display ),
		Display( Size( 394, 16 ), :Year )
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or, you could turn the Year column into an actual JMP Date value, and place a date format on the column, and you will see a much nicer slider version of the code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt=open("$SAMPLE_DATA\Movies.jmp");
for each row(
dt:year= date mdy(1,1,year));
dt:year &amp;lt;&amp;lt; format("m/d/y");
Current Data Table() &amp;lt;&amp;lt; Data Filter(
	Location( {37, 37} ),
	Add Filter(
		columns( :Type, :Year ),
		Display( :Type, Size( 160, 90 ), List Display ),
		Display( Size( 394, 16 ), :Year )
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 23 May 2017 01:07:56 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2017-05-23T01:07:56Z</dc:date>
    <item>
      <title>Script: Data Table Subset With Combo Box Filters</title>
      <link>https://community.jmp.com/t5/Discussions/Script-Data-Table-Subset-With-Combo-Box-Filters/m-p/39524#M23110</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have been trying to write a script to create a subset of a larger data table. &amp;nbsp;The new subset should contain a subject ID number, D.O.B, and a Range of Selected Dates. &amp;nbsp;I wrote a script that asks for the ID#, start date, and end date in three different text boxes. (Included below, and it's far from perfect). &amp;nbsp;However, I would like some drop down menus in the pop-up window as to show what ID#s are available for the current data table, and the accompanying dates for that subject. Following the example from here, &lt;A href="http://www.jmp.com/support/notes/54/614.html" target="_blank"&gt;http://www.jmp.com/support/notes/54/614.html&lt;/A&gt;, I have tried working with Combo Boxes, but&amp;nbsp;can't seem to get it right.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Where the problem comes down to is making the second/third drop down menu&amp;nbsp;react accordingly to the ID# selection. Things I have noticed: Summarize and Associative Array help reduce duplicate dates and white spaces, and dates are not in the prefered "m/d/y".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any Help Appreciated!&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Current Data Table();

Column(dt, "Coll Date") &amp;lt;&amp;lt; Data Type("Numeric", Informat("m/d/y"), Format("m/d/y") );
Column(dt, "Coll Date") &amp;lt;&amp;lt; Modeling Type("Continuous");
Column(dt, "Coll Date") &amp;lt;&amp;lt; Order(Ascending);

nw = New Window( "Subject ID by Date Range.",
	&amp;lt;&amp;lt;Modal,
	V List Box( Text Box( "Select an ID# and Date Range. " ), Spacer Box( Size( 25, 25 ) ) ),
	V List Box(
		Lineup Box(
			3,
			Text Box( "Subject ID: " ),
			sub = Number Edit Box( . ),
			Text Box( "Start Date: " ),
			start = Text Edit Box( . ),
			Text Box( "End Date: " ),
			end = Text Edit Box( . )
		),
		Spacer Box( Size( 25, 25 ) ),
		H List Box(
			Button Box( "Click to Update First",
				subid = sub &amp;lt;&amp;lt; Get;
				startDate = start &amp;lt;&amp;lt; Get Text;
				endDate = end &amp;lt;&amp;lt; Get Text;
			)
		)
	)
);
For Each Row(
	Selected( Row State() ) = :Patient ID1 == subid &amp;amp; Format( :Coll Date, "m/d/y" )
	 &amp;gt;= Char( startDate ) &amp;amp; Format( :Coll Date, "m/d/y" ) &amp;lt;= Char( endDate )
);
subdt = dt &amp;lt;&amp;lt; Subset(
	Columns( :Patient ID1, :DOB, :Coll Date ),
	Output Table Name( "subset" ), 
);
subdt&amp;lt;&amp;lt; sort(by(:Coll Date), Replace Table);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;A&lt;/P&gt;</description>
      <pubDate>Mon, 22 May 2017 21:07:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Script-Data-Table-Subset-With-Combo-Box-Filters/m-p/39524#M23110</guid>
      <dc:creator>FaxMachine</dc:creator>
      <dc:date>2017-05-22T21:07:12Z</dc:date>
    </item>
    <item>
      <title>Re: Script: Data Table Subset With Combo Box Filters</title>
      <link>https://community.jmp.com/t5/Discussions/Script-Data-Table-Subset-With-Combo-Box-Filters/m-p/39525#M23111</link>
      <description>This is where I stand on using Combo Boxes, it's a big mess...&lt;BR /&gt;&lt;BR /&gt;dt = Current Data Table();&lt;BR /&gt;&lt;BR /&gt;Column( dt, "Coll Date" ) &amp;lt;&amp;lt; Data Type( "Character", Informat( "d/m/y" ), Format( "m/d/y" ) );&lt;BR /&gt;Column( dt, "Coll Date" ) &amp;lt;&amp;lt; Modeling Type( "Continuous" );&lt;BR /&gt;Column( dt, "Coll Date" ) &amp;lt;&amp;lt; Order( Ascending );&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Summarize( a = By( :Patient ID1 ) );&lt;BR /&gt;Insert Into( a, "&amp;lt;Select ID#&amp;gt;", 1 );&lt;BR /&gt;//Summarize( b = By( :Coll Date ) );&lt;BR /&gt;date = Associative Array( ( :Coll Date &amp;lt;&amp;lt; Get Values ) ) &amp;lt;&amp;lt; Get Keys;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;New Window( "Example",&lt;BR /&gt;&amp;lt;&amp;lt;Modal,&lt;BR /&gt;H List Box(&lt;BR /&gt;Panel Box( "Select Patient ID: ",&lt;BR /&gt;cb1 = Combo Box(&lt;BR /&gt;a,&lt;BR /&gt;&amp;lt;&amp;lt;SetFunction(&lt;BR /&gt;Function( {this},&lt;BR /&gt;selection = this &amp;lt;&amp;lt; Get Selected();&lt;BR /&gt;r = //For Each Row( Selected(Row State() = :Patient ID1 == Num(selection)));&lt;BR /&gt;dt &amp;lt;&amp;lt; Get Rows Where( :Patient ID == Num( selection ) );&lt;BR /&gt;Summarize( b = By( :Coll Date[r] ) );&lt;BR /&gt;b &amp;lt;&amp;lt; Data Type( "Character", Informat( "d/m/y" ), Format( "m/d/y" ) );&lt;BR /&gt;//b = Associative Array( (:Coll Date[r] &amp;lt;&amp;lt; Get Values)) &amp;lt;&amp;lt; Get Keys;&lt;BR /&gt;//startDate = Associative Array( (date[r] &amp;lt;&amp;lt; Get Values ) ) &amp;lt;&amp;lt; Get Keys;&lt;BR /&gt;cb2 &amp;lt;&amp;lt; Set Items( date[r] );&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;),&lt;BR /&gt;&lt;BR /&gt;Panel Box( "Select a Start Date: ",&lt;BR /&gt;cb2 = Combo Box(&lt;BR /&gt;b,&lt;BR /&gt;&amp;lt;&amp;lt;SetFunction(&lt;BR /&gt;Function( {this},&lt;BR /&gt;one = this &amp;lt;&amp;lt; Get Selected();&lt;BR /&gt;g = dt &amp;lt;&amp;lt; Get Rows Where( :Coll Date &amp;gt; one );&lt;BR /&gt;Summarize( c = By( :Coll Date[g] ) );&lt;BR /&gt;endDate = :Coll Date[g];&lt;BR /&gt;cb3 &amp;lt;&amp;lt; Set Items( endDate );&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;),&lt;BR /&gt;&lt;BR /&gt;Panel Box( "Select an End Date: ",&lt;BR /&gt;cb3 = Combo Box(&lt;BR /&gt;b,&lt;BR /&gt;&amp;lt;&amp;lt;SetFunction(&lt;BR /&gt;Function( {this},&lt;BR /&gt;two = this &amp;lt;&amp;lt; Get Selected() ) )&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;);&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;For Each Row(&lt;BR /&gt;Selected( Row State() ) = :Patient ID1 == Char( Selection ) &amp;amp; Format( :Coll Date, "m/d/y" ) &amp;gt;= one&lt;BR /&gt;&amp;amp; Format( :Coll Date, "m/d/y" ) &amp;lt;= two&lt;BR /&gt;);&lt;BR /&gt;&lt;BR /&gt;subdt = dt &amp;lt;&amp;lt; Subset( Columns( :Patient ID1, :DOB, :Coll Date ), Output Table Name( "Subset" ), );&lt;BR /&gt;&lt;BR /&gt;subdt &amp;lt;&amp;lt; Sort( By( :Coll Date ), Replace Table );</description>
      <pubDate>Mon, 22 May 2017 21:18:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Script-Data-Table-Subset-With-Combo-Box-Filters/m-p/39525#M23111</guid>
      <dc:creator>FaxMachine</dc:creator>
      <dc:date>2017-05-22T21:18:09Z</dc:date>
    </item>
    <item>
      <title>Re: Script: Data Table Subset With Combo Box Filters</title>
      <link>https://community.jmp.com/t5/Discussions/Script-Data-Table-Subset-With-Combo-Box-Filters/m-p/39528#M23114</link>
      <description>&lt;P&gt;You certainly can create your own unique dialog box, with the requirements you specified, but the simple way of doing what you want is to script a data fileter, then using the builtin selection capability, the user can then simply go to the red triangle and select "Show Subset" and the data table you wrote about will be created&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt=open("$SAMPLE_DATA\Movies.jmp");
Current Data Table() &amp;lt;&amp;lt; Data Filter(
	Location( {37, 37} ),
	Add Filter(
		columns( :Type, :Year ),
		Display( :Type, Size( 160, 90 ), List Display ),
		Display( Size( 394, 16 ), :Year )
	)
);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 22 May 2017 23:26:55 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Script-Data-Table-Subset-With-Combo-Box-Filters/m-p/39528#M23114</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2017-05-22T23:26:55Z</dc:date>
    </item>
    <item>
      <title>Re: Script: Data Table Subset With Combo Box Filters</title>
      <link>https://community.jmp.com/t5/Discussions/Script-Data-Table-Subset-With-Combo-Box-Filters/m-p/39529#M23115</link>
      <description>&lt;P&gt;oh wow, a lot simpler!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Following the samle data, selecting the movie Type is great, would it be possible to get something similar for the Year column. &amp;nbsp;Maybe format the type to get discrete values as opposed to a year down to the third decimal place?&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 00:34:36 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Script-Data-Table-Subset-With-Combo-Box-Filters/m-p/39529#M23115</guid>
      <dc:creator>FaxMachine</dc:creator>
      <dc:date>2017-05-23T00:34:36Z</dc:date>
    </item>
    <item>
      <title>Re: Script: Data Table Subset With Combo Box Filters</title>
      <link>https://community.jmp.com/t5/Discussions/Script-Data-Table-Subset-With-Combo-Box-Filters/m-p/39534#M23116</link>
      <description>&lt;P&gt;The selection device, pick list vs. slider is based upon what the modeling type for the column is.&amp;nbsp; If you just change the modeling type to "Ordinal" it will make the selection a pick list.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt=open("$SAMPLE_DATA\Movies.jmp");
dt:year &amp;lt;&amp;lt; set modeling type(ordinal);
Current Data Table() &amp;lt;&amp;lt; Data Filter(
	Location( {37, 37} ),
	Add Filter(
		columns( :Type, :Year ),
		Display( :Type, Size( 160, 90 ), List Display ),
		Display( Size( 394, 16 ), :Year )
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or, you could turn the Year column into an actual JMP Date value, and place a date format on the column, and you will see a much nicer slider version of the code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt=open("$SAMPLE_DATA\Movies.jmp");
for each row(
dt:year= date mdy(1,1,year));
dt:year &amp;lt;&amp;lt; format("m/d/y");
Current Data Table() &amp;lt;&amp;lt; Data Filter(
	Location( {37, 37} ),
	Add Filter(
		columns( :Type, :Year ),
		Display( :Type, Size( 160, 90 ), List Display ),
		Display( Size( 394, 16 ), :Year )
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 May 2017 01:07:56 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Script-Data-Table-Subset-With-Combo-Box-Filters/m-p/39534#M23116</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2017-05-23T01:07:56Z</dc:date>
    </item>
    <item>
      <title>Re: Script: Data Table Subset With Combo Box Filters</title>
      <link>https://community.jmp.com/t5/Discussions/Script-Data-Table-Subset-With-Combo-Box-Filters/m-p/314791#M56692</link>
      <description>&lt;P&gt;How do you script showing the subset table part?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 22:23:04 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Script-Data-Table-Subset-With-Combo-Box-Filters/m-p/314791#M56692</guid>
      <dc:creator>Tinkerbell</dc:creator>
      <dc:date>2020-09-29T22:23:04Z</dc:date>
    </item>
  </channel>
</rss>

