<?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: How do I make combo box to  show unique values? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-do-I-make-combo-box-to-show-unique-values/m-p/659512#M84875</link>
    <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/33497"&gt;@lehaofeng&lt;/a&gt;&amp;nbsp;&amp;nbsp;Could you create a new discussion with example script?&lt;/P&gt;</description>
    <pubDate>Tue, 18 Jul 2023 05:35:31 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2023-07-18T05:35:31Z</dc:date>
    <item>
      <title>How do I make combo box to  show unique values?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-make-combo-box-to-show-unique-values/m-p/43390#M25126</link>
      <description>&lt;P&gt;Dear All,&lt;/P&gt;&lt;P&gt;This script is similar to one in book&amp;nbsp;"JUMP into JMP".&lt;/P&gt;&lt;P&gt;The script prompts user to select a "DCM", based on this selection "DieNo" list is populated.&lt;/P&gt;&lt;P&gt;There are couple of problems here. "DCM Number" list is not in ascending order.&lt;/P&gt;&lt;P&gt;Other issue, When I select a DCM number, "DieNo" list is populated. But this lists all the values, I want only unique values to be listed.&lt;/P&gt;&lt;P&gt;For both columns data type is char, however numeric datatype doesn't work here. Any advice on this problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;/* Open the sample data table */
dt = Open( "$Desktop/JMP scripts/SampleData.jmp" );

/* Create lists of the values found in the DCMNo and Die columns*/
Unique DCM=Associative array(dt:DCMNo);
nitems(unique DCM);
DCM1= unique DCM&amp;lt;&amp;lt;get keys;
DCM=Sort Ascending(DCM1);
Unique Die=Associative array(dt:DieNo);
nitems(unique Die);
Die= unique Die&amp;lt;&amp;lt;get keys;
dt &amp;lt;&amp;lt; Clear Column Selection();
dt &amp;lt;&amp;lt; Clear row Selection();

/* Use New Window to create a non-modal dialog to display DCMNo and Die for user to choose. */
nw = New Window( "Choose DCM Die combination",
	hb = H List Box(
		Panel Box( "Select a DCM Number",
			select1 = Combo Box(
				DCM,  
/* Each of the following tasks are executed when the user makes a DCMNo choice.*/
				dt &amp;lt;&amp;lt; Select Where( :DCMNo == DCM[select1 &amp;lt;&amp;lt; get] );
				selRows = dt &amp;lt;&amp;lt; Get Selected Rows;
				pb &amp;lt;&amp;lt; delete;
				myDies = {};
/* The myDies list is populated with values from the selected DCMNo. */
				For( i = 1, i &amp;lt;= N Row( selRows ), i++,
					Insert Into( myDies, Column( dt, "DieNo" )[selRows[i]] )
				);
/* A new panel box is drawn and values shown are based on DCMNo selection. */
				hb &amp;lt;&amp;lt; Append( pb = Panel Box( "Select a Die", select2 = Combo Box( myDies ) ) );
			)
		),
		pb = Panel Box( "Select a Die", Combo Box( " " ) )
	),  
/* If user clicks OK, values displayed for DCMNo and Die will be selected in table. */
	Button Box( "OK",
		nw &amp;lt;&amp;lt; Close Window;
		dt &amp;lt;&amp;lt; Select where( :DCMNo == DCM[select1 &amp;lt;&amp;lt; get] &amp;amp; :DieNo == myDies[select2 &amp;lt;&amp;lt; get] );
/* Selected rows are subsetted into new table. */
		rows=dt &amp;lt;&amp;lt; get selected rows;
		dt &amp;lt;&amp;lt; subset( Output Table Name( "Ryobi Details" ) );
	)
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I&amp;nbsp;am also trying to include&amp;nbsp;date selection combo box. The best post and easy option for this was "date data filter".&lt;/P&gt;&lt;P&gt;Does JMP allow me to show a calender for dates {A wee calender as shown when we book flights from depature date to arrival date}.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;San&lt;/P&gt;</description>
      <pubDate>Fri, 18 Aug 2017 11:28:21 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-make-combo-box-to-show-unique-values/m-p/43390#M25126</guid>
      <dc:creator>sanqub</dc:creator>
      <dc:date>2017-08-18T11:28:21Z</dc:date>
    </item>
    <item>
      <title>Re: How do I make combo box to  show unique values?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-make-combo-box-to-show-unique-values/m-p/43391#M25127</link>
      <description>&lt;P&gt;The DCM list is alphabetically in order. You are interpreting the DCM as a number. JMP is interpreting DCM as a character string.&lt;/P&gt;
&lt;P&gt;Why won't numeric values work for DCM or Die? That data type would solve your ordering problem.&lt;/P&gt;
&lt;P&gt;I cleaned up a few things for a shorter solution. Here it is:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here( 1 );

/* Open the sample data table */
dt = Open( "$Desktop/SampleData.jmp" );

/* Create lists of the values found in the DCMNo and Die columns*/
DCM = Sort Ascending( Associative Array( dt:DCMNo ) &amp;lt;&amp;lt; Get Keys );
Die = Associative Array( dt:DieNo ) &amp;lt;&amp;lt; Get Keys;

selRows = dt &amp;lt;&amp;lt; Get Rows Where( :DCMNo == DCM[1] );
initial Die Set = Associative Array( Column( dt, "DieNo" )[selRows] ) &amp;lt;&amp;lt; Get Keys;

dt &amp;lt;&amp;lt; Clear Column Selection();
dt &amp;lt;&amp;lt; Clear Row Selection();

/* Use New Window to create a non-modal dialog to display DCMNo and Die for user to choose. */
nw = New Window( "Choose DCM Die combination",
	hb = H List Box(
		Panel Box( "Select a DCM Number",
			select1 = Combo Box( DCM,  
/* Each of the following tasks are executed when the user makes a DCMNo choice.*/
				selRows = dt &amp;lt;&amp;lt; Get Rows Where( :DCMNo == DCM[select1 &amp;lt;&amp;lt; Get] );
				myDies = Associative Array( Column( dt, "DieNo" )[selRows] ) &amp;lt;&amp;lt; Get Keys;
				select2 &amp;lt;&amp;lt; Set Items( myDies );
			)
		),
		Panel Box( "Select a Die",
			select2 = Combo Box( initial Die Set )
		)
	),  
/* If user clicks OK, values displayed for DCMNo and Die will be selected in table. */
	Button Box( "OK",
		nw &amp;lt;&amp;lt; Close Window;
		dt &amp;lt;&amp;lt; Select where( :DCMNo == DCM[select1 &amp;lt;&amp;lt; Get] &amp;amp; :DieNo == myDies[select2 &amp;lt;&amp;lt; Get] );
/* Selected rows are subsetted into new table. */
		dt &amp;lt;&amp;lt; Subset( Output Table Name( "Ryobi Details" ) );
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 18 Aug 2017 12:09:03 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-make-combo-box-to-show-unique-values/m-p/43391#M25127</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2017-08-18T12:09:03Z</dc:date>
    </item>
    <item>
      <title>Re: How do I make combo box to  show unique values?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-make-combo-box-to-show-unique-values/m-p/43393#M25128</link>
      <description>&lt;P&gt;Also, you can use a Number Edit Box() with a date format or the new Calendar Box(). They both work well but present a different interface to the user.&lt;/P&gt;
&lt;P&gt;Here is the Number Edit Box() approach, from the Scripting Index:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
New Window( "Example",
	fontobj = numbox = Number Edit Box( 0 )
);
numbox &amp;lt;&amp;lt; Set Format( Format( "m/d/y", 12 ) );
numbox &amp;lt;&amp;lt; Set( Date MDY( 10, 2, 1989 ) );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here is the Calendar Box() solution, also taken from the Scripting Index:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
New Window( "Calendar Box Example",
	cal = Calendar Box()
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 18 Aug 2017 11:59:37 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-make-combo-box-to-show-unique-values/m-p/43393#M25128</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2017-08-18T11:59:37Z</dc:date>
    </item>
    <item>
      <title>Re: How do I make combo box to  show unique values?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-make-combo-box-to-show-unique-values/m-p/43397#M25129</link>
      <description>&lt;P&gt;I didn't know about the new calendar box() display box in JMP 13. &amp;nbsp;Nice! &amp;nbsp;How do you use it though? &amp;nbsp;I had to make the dialog box modal to get it to return something.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
New Window( "Calendar Box Example", &amp;lt;&amp;lt; modal(),
	cal = Calendar Box()
);

selected_date = format(cal &amp;lt;&amp;lt; get date, "ddMonyyyy");
print(selected_date);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 18 Aug 2017 12:20:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-make-combo-box-to-show-unique-values/m-p/43397#M25129</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2017-08-18T12:20:45Z</dc:date>
    </item>
    <item>
      <title>Re: How do I make combo box to  show unique values?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-make-combo-box-to-show-unique-values/m-p/43405#M25135</link>
      <description>&lt;P&gt;You do not need a modal window to use the Calendar Box.&lt;/P&gt;
&lt;P&gt;The Calendar Box works like a specialized Number Edit Box. It handles dates for you so you do not have to mess with formats or convert seconds to dates or time.&lt;/P&gt;
&lt;P&gt;See the Scripting Index or the Scripting Guide&amp;nbsp;for the message protocol.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Aug 2017 13:45:18 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-make-combo-box-to-show-unique-values/m-p/43405#M25135</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2017-08-18T13:45:18Z</dc:date>
    </item>
    <item>
      <title>Re: How do I make combo box to  show unique values?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-make-combo-box-to-show-unique-values/m-p/43407#M25137</link>
      <description>&lt;P&gt;The scripting index and guide are somewhat weak with regard to this new function. &amp;nbsp;The examples in the scripting guide could be beefed up a bit. &amp;nbsp;Here's a better one that displays the calendar. &amp;nbsp;When you select a date and click OK that is printed in the log window.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
nw = New Window( "Calendar Box Example", 
	cal = Calendar Box(),
	ok_button = button box("OK",
		selected_date = format(cal &amp;lt;&amp;lt; get date, "ddMonyyyy");
		print(selected_date);
		nw &amp;lt;&amp;lt; close window;
	)
);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 18 Aug 2017 14:15:25 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-make-combo-box-to-show-unique-values/m-p/43407#M25137</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2017-08-18T14:15:25Z</dc:date>
    </item>
    <item>
      <title>Re: How do I make combo box to  show unique values?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-make-combo-box-to-show-unique-values/m-p/659511#M84874</link>
      <description>&lt;P&gt;Why is it that if I don't select the other numbers in the drop down box and use the default, it gives me an error; if I select the other numbers, it doesn't give me an error.&lt;BR /&gt;I'm version 17, mac.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jul 2023 05:10:05 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-make-combo-box-to-show-unique-values/m-p/659511#M84874</guid>
      <dc:creator>lehaofeng</dc:creator>
      <dc:date>2023-07-18T05:10:05Z</dc:date>
    </item>
    <item>
      <title>Re: How do I make combo box to  show unique values?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-make-combo-box-to-show-unique-values/m-p/659512#M84875</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/33497"&gt;@lehaofeng&lt;/a&gt;&amp;nbsp;&amp;nbsp;Could you create a new discussion with example script?&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jul 2023 05:35:31 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-make-combo-box-to-show-unique-values/m-p/659512#M84875</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2023-07-18T05:35:31Z</dc:date>
    </item>
    <item>
      <title>Re: How do I make combo box to  show unique values?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-make-combo-box-to-show-unique-values/m-p/659515#M84876</link>
      <description>&lt;P&gt;It's Mark's script and the data provided in this post that I've found in running it that pressing the default dropdown box numbers without changing them gives me an error; selecting other numbers is fine.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;/* Open the sample data table */
dt = Open( "$Desktop/SampleData.jmp" );

/* Create lists of the values found in the DCMNo and Die columns*/
DCM = Sort Ascending( Associative Array( dt:DCMNo ) &amp;lt;&amp;lt; Get Keys );
Die = Associative Array( dt:DieNo ) &amp;lt;&amp;lt; Get Keys;

selRows = dt &amp;lt;&amp;lt; Get Rows Where( :DCMNo == DCM[1] );
initial Die Set = Associative Array( Column( dt, "DieNo" )[selRows] ) &amp;lt;&amp;lt; Get Keys;

dt &amp;lt;&amp;lt; Clear Column Selection();
dt &amp;lt;&amp;lt; Clear Row Selection();

/* Use New Window to create a non-modal dialog to display DCMNo and Die for user to choose. */
nw = New Window( "Choose DCM Die combination",
	hb = H List Box(
		Panel Box( "Select a DCM Number",
			select1 = Combo Box( DCM,  
/* Each of the following tasks are executed when the user makes a DCMNo choice.*/
				selRows = dt &amp;lt;&amp;lt; Get Rows Where( :DCMNo == DCM[select1 &amp;lt;&amp;lt; Get] );
				myDies = Associative Array( Column( dt, "DieNo" )[selRows] ) &amp;lt;&amp;lt; Get Keys;
				select2 &amp;lt;&amp;lt; Set Items( myDies );
			)
		),
		Panel Box( "Select a Die",
			select2 = Combo Box( initial Die Set )
		)
	),  
/* If user clicks OK, values displayed for DCMNo and Die will be selected in table. */
	Button Box( "OK",
		nw &amp;lt;&amp;lt; Close Window;
		dt &amp;lt;&amp;lt; Select where( :DCMNo == DCM[select1 &amp;lt;&amp;lt; Get] &amp;amp; :DieNo == myDies[select2 &amp;lt;&amp;lt; Get] );
/* Selected rows are subsetted into new table. */
		dt &amp;lt;&amp;lt; Subset( Output Table Name( "Ryobi Details" ) );
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 18 Jul 2023 05:46:13 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-make-combo-box-to-show-unique-values/m-p/659515#M84876</guid>
      <dc:creator>lehaofeng</dc:creator>
      <dc:date>2023-07-18T05:46:13Z</dc:date>
    </item>
    <item>
      <title>Re: How do I make combo box to  show unique values?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-make-combo-box-to-show-unique-values/m-p/659518#M84877</link>
      <description>&lt;P&gt;Very quickly checking the script, the issues is that the script inside combo box isn't triggered on initial creation. Most simple fix is to add something like&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;select1 &amp;lt;&amp;lt; Set(2, Run Script(0));
select1 &amp;lt;&amp;lt; Set(1, Run Script(1));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to end of script. This will change the value in combo box and then trigger the script once.&lt;/P&gt;
&lt;P&gt;Other fairly easy option would be to change the script inside the Combo Box to expression and then run it once the window has been created.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-SPOILER&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);


/* Open the sample data table */
dt = Open("$DOWNLOADS/SampleData.jmp");

/* Create lists of the values found in the DCMNo and Die columns*/
DCM = Sort Ascending(Associative Array(dt:DCMNo) &amp;lt;&amp;lt; Get Keys);
Die = Associative Array(dt:DieNo) &amp;lt;&amp;lt; Get Keys;

selRows = dt &amp;lt;&amp;lt; Get Rows Where(:DCMNo == DCM[1]);
initial Die Set = Associative Array(Column(dt, "DieNo")[selRows]) &amp;lt;&amp;lt; Get Keys;

dt &amp;lt;&amp;lt; Clear Column Selection();
dt &amp;lt;&amp;lt; Clear Select;

sel_expr = Expr(
	selRows = dt &amp;lt;&amp;lt; Get Rows Where(:DCMNo == DCM[select1 &amp;lt;&amp;lt; Get]);
	myDies = Associative Array(Column(dt, "DieNo")[selRows]) &amp;lt;&amp;lt; Get Keys;
	select2 &amp;lt;&amp;lt; Set Items(myDies);
);

/* Use New Window to create a non-modal dialog to display DCMNo and Die for user to choose. */
nw = New Window("Choose DCM Die combination",
	hb = H List Box(
		Panel Box("Select a DCM Number",
			select1 = Combo Box(
				DCM,  
/* Each of the following tasks are executed when the user makes a DCMNo choice.*/
				sel_expr
			)
		),
		Panel Box("Select a Die", select2 = Combo Box(initial Die Set))
	),  
/* If user clicks OK, values displayed for DCMNo and Die will be selected in table. */
	Button Box("OK",
		nw &amp;lt;&amp;lt; Close Window;
		dt &amp;lt;&amp;lt; Select where(:DCMNo == DCM[select1 &amp;lt;&amp;lt; Get] &amp;amp; :DieNo == myDies[select2 &amp;lt;&amp;lt; Get]);
/* Selected rows are subsetted into new table. */
		dt &amp;lt;&amp;lt; Subset(Output Table Name("Ryobi Details"));
	)
);

sel_expr;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI-SPOILER&gt;
&lt;P&gt;Or use &amp;lt;&amp;lt; Get Function at the end of script with Eval&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Eval(select1 &amp;lt;&amp;lt; get function);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 18 Jul 2023 06:21:48 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-make-combo-box-to-show-unique-values/m-p/659518#M84877</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2023-07-18T06:21:48Z</dc:date>
    </item>
    <item>
      <title>Re: How do I make combo box to  show unique values?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-make-combo-box-to-show-unique-values/m-p/659531#M84879</link>
      <description>&lt;P&gt;Thank you !&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jul 2023 08:34:47 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-make-combo-box-to-show-unique-values/m-p/659531#M84879</guid>
      <dc:creator>lehaofeng</dc:creator>
      <dc:date>2023-07-18T08:34:47Z</dc:date>
    </item>
  </channel>
</rss>

