<?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 Query Script in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Query-Script/m-p/44493#M25510</link>
    <description>&lt;P&gt;I am creating a script that starts with a modal window and runs a couple of stored procedures and automatically joins the resulting tables. These are fairly large tables, and I want to add an option for the user to run something similar to the Query Builder, where they can select columns as filters and input the data they want filtered.&amp;nbsp;&lt;/P&gt;&lt;P&gt;How would I go about doing this before the tables are open? I want to minimize the time it takes to run the procedures and join the tables, so filtering the data after the final table is open isn't really what I want to do.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestions would be greatly appreciated!&lt;/P&gt;</description>
    <pubDate>Wed, 13 Sep 2017 22:24:37 GMT</pubDate>
    <dc:creator>aallman</dc:creator>
    <dc:date>2017-09-13T22:24:37Z</dc:date>
    <item>
      <title>Query Script</title>
      <link>https://community.jmp.com/t5/Discussions/Query-Script/m-p/44493#M25510</link>
      <description>&lt;P&gt;I am creating a script that starts with a modal window and runs a couple of stored procedures and automatically joins the resulting tables. These are fairly large tables, and I want to add an option for the user to run something similar to the Query Builder, where they can select columns as filters and input the data they want filtered.&amp;nbsp;&lt;/P&gt;&lt;P&gt;How would I go about doing this before the tables are open? I want to minimize the time it takes to run the procedures and join the tables, so filtering the data after the final table is open isn't really what I want to do.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestions would be greatly appreciated!&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2017 22:24:37 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Query-Script/m-p/44493#M25510</guid>
      <dc:creator>aallman</dc:creator>
      <dc:date>2017-09-13T22:24:37Z</dc:date>
    </item>
    <item>
      <title>Re: Query Script</title>
      <link>https://community.jmp.com/t5/Discussions/Query-Script/m-p/44506#M25519</link>
      <description>&lt;P&gt;You can add prompts to your modal window to prefilter the data. &amp;nbsp;Here's a simple example that allows a user to pre-select products and locations before the query runs. &amp;nbsp;I've hardcoded the list of values to choose from, but ideally you would get this dynamically with SQL queries.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// Hardcode or get dynamically from the database
product_list = {"AAAA", "BBBB", "CCCC", "DDDD"};

// Hardcode or get dynamically from the database
location_list = {"China", "England", "Germany", "Italy", "Japan", "USA"};

nw = new window("Get Data", &amp;lt;&amp;lt; modal,
	panel box("Pre-Filter",
		hlistbox(
			product_cb  = listbox(product_list),
			location_cb = listbox(location_list)
		),
	),
	panel box("Actions",
		hlistbox(
			button box("OK",
				ok_pushed = 1;
				selected_products  = product_cb  &amp;lt;&amp;lt; get selected;
				selected_locations = location_cb &amp;lt;&amp;lt; get selected
			),
			button box("Cancel",
				ok_pushed = 0;
			)
		)
	)
);

if (ok_pushed,
	product_in_list = "";
	location_in_list = "";

	print(selected_products, selected_locations);
	if (nitems(selected_products) &amp;gt; 0,
		product_in_list = "t.products IN ('" || 
			concat items(selected_products, "', '") || "')";
	);
	if (nitems(selected_locations) &amp;gt; 0,
		location_in_list = "t.locations IN ('" || 
			concat items(selected_locations, "', '") || "')";
	);

	print(product_in_list, location_in_list);
	// run SQL query
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="prefilter.png" style="width: 481px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/7524iEB7DCDB6CC1ECECE/image-size/large?v=v2&amp;amp;px=999" role="button" title="prefilter.png" alt="prefilter.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Output from log:&lt;/P&gt;
&lt;PRE&gt;{"AAAA", "CCCC"}
{"England", "Germany", "Italy"}
"t.products IN ('AAAA', 'CCCC')"
"t.locations IN ('England', 'Germany', 'Italy')"&lt;/PRE&gt;</description>
      <pubDate>Thu, 14 Sep 2017 12:31:14 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Query-Script/m-p/44506#M25519</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2017-09-14T12:31:14Z</dc:date>
    </item>
    <item>
      <title>Re: Query Script</title>
      <link>https://community.jmp.com/t5/Discussions/Query-Script/m-p/44514#M25521</link>
      <description>&lt;P&gt;How would I get the user to select the filter? Like if I wanted to open the data tables but I only wanted where :Length was between 20-40 and :Scale was 25 nanomoles. But I want the user to be able to select which filters they want to apply from the available columns.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Sep 2017 13:35:38 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Query-Script/m-p/44514#M25521</guid>
      <dc:creator>aallman</dc:creator>
      <dc:date>2017-09-14T13:35:38Z</dc:date>
    </item>
    <item>
      <title>Re: Query Script</title>
      <link>https://community.jmp.com/t5/Discussions/Query-Script/m-p/44520#M25525</link>
      <description>&lt;P&gt;Would I be able to build a filter if I ran the stored procedures, got a full list of columns and their data types, and somehow used those as options? It ends up being around 45 columns, so if there is anything better please let me know!&lt;/P&gt;</description>
      <pubDate>Thu, 14 Sep 2017 14:11:36 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Query-Script/m-p/44520#M25525</guid>
      <dc:creator>aallman</dc:creator>
      <dc:date>2017-09-14T14:11:36Z</dc:date>
    </item>
    <item>
      <title>Re: Query Script</title>
      <link>https://community.jmp.com/t5/Discussions/Query-Script/m-p/44524#M25526</link>
      <description>&lt;P&gt;A general solution to this would be pretty complicated. &amp;nbsp;You could build a dialog box with a fixed number of&amp;nbsp;selections to make.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// Get numeric column names from sample data
dt = open("$sample_data\Boston Housing.jmp");

col_list = dt &amp;lt;&amp;lt; get column names("String", numeric);
insertinto(col_list, "&amp;lt;no selection&amp;gt;", 1);

nw = new window("Get Data2",
	panel box("Filter Data",
		lineup box(ncol(3),
			text box("Column"), text box("Low Value"), text box("High Value"),
			cb1   = combo box(col_list),
			low1  = number edit box(),
			high1 = number edit box(),

			cb2   = combo box(col_list),
			low2  = number edit box(),
			high2 = number edit box(),

			cb3   = combo box(col_list),
			low3  = number edit box(),
			high3 = number edit box(),

// Add more columns if needed...
		)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ColSelection.png" style="width: 350px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/7533iF79481C9A00EC605/image-size/large?v=v2&amp;amp;px=999" role="button" title="ColSelection.png" alt="ColSelection.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Sep 2017 16:00:49 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Query-Script/m-p/44524#M25526</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2017-09-14T16:00:49Z</dc:date>
    </item>
  </channel>
</rss>

