<?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 Graph Builder Bar Graph filter by top 10 Sums in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Graph-Builder-Bar-Graph-filter-by-top-10-Sums/m-p/186735#M40520</link>
    <description>&lt;P&gt;I have a horizontal stacked bar graph and want to limit it to just the top 10 sums by Y-axis category.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The data has a year's worth of customer orders.&amp;nbsp; Each row is an order line item that has a customer, a value and a customer country (among other data).&amp;nbsp; The x-axis is summary statistic sum of the order value.&amp;nbsp; The y-axis is the customer name.&amp;nbsp; And the stacking (overlay) is by the customer country.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My goal is to not show all 1,000 customers, but rather just the top 10 by the total of their order values.&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The script at the moment looks like this, where sales org. is the customer country&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Graph Builder(
	Size( 905, 603 ),
	Variables(
		X( :Total Dollars Ordered ),
		Y(
			:Customer,
			Order By( :Total Dollars Ordered, Ascending, Order Statistic( "Sum" ) )
		),
		Overlay( :Sales Organization Code )
	),
	Elements(
		Bar( X, Y, Legend( 4 ), Bar Style( "Stacked" ), Summary Statistic( "Sum" ) )
	),
	SendToReport(
		Dispatch(
			{},
			"graph title",
			TextEditBox,
			{Set Text( "Total Dollars Ordered by Customer" )}
		)
	)
)&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 13 Mar 2019 17:35:24 GMT</pubDate>
    <dc:creator>BSwid</dc:creator>
    <dc:date>2019-03-13T17:35:24Z</dc:date>
    <item>
      <title>Graph Builder Bar Graph filter by top 10 Sums</title>
      <link>https://community.jmp.com/t5/Discussions/Graph-Builder-Bar-Graph-filter-by-top-10-Sums/m-p/186735#M40520</link>
      <description>&lt;P&gt;I have a horizontal stacked bar graph and want to limit it to just the top 10 sums by Y-axis category.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The data has a year's worth of customer orders.&amp;nbsp; Each row is an order line item that has a customer, a value and a customer country (among other data).&amp;nbsp; The x-axis is summary statistic sum of the order value.&amp;nbsp; The y-axis is the customer name.&amp;nbsp; And the stacking (overlay) is by the customer country.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My goal is to not show all 1,000 customers, but rather just the top 10 by the total of their order values.&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The script at the moment looks like this, where sales org. is the customer country&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Graph Builder(
	Size( 905, 603 ),
	Variables(
		X( :Total Dollars Ordered ),
		Y(
			:Customer,
			Order By( :Total Dollars Ordered, Ascending, Order Statistic( "Sum" ) )
		),
		Overlay( :Sales Organization Code )
	),
	Elements(
		Bar( X, Y, Legend( 4 ), Bar Style( "Stacked" ), Summary Statistic( "Sum" ) )
	),
	SendToReport(
		Dispatch(
			{},
			"graph title",
			TextEditBox,
			{Set Text( "Total Dollars Ordered by Customer" )}
		)
	)
)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Mar 2019 17:35:24 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Graph-Builder-Bar-Graph-filter-by-top-10-Sums/m-p/186735#M40520</guid>
      <dc:creator>BSwid</dc:creator>
      <dc:date>2019-03-13T17:35:24Z</dc:date>
    </item>
    <item>
      <title>Re: Graph Builder Bar Graph filter by top 10 Sums</title>
      <link>https://community.jmp.com/t5/Discussions/Graph-Builder-Bar-Graph-filter-by-top-10-Sums/m-p/186762#M40522</link>
      <description>&lt;P&gt;I suggest that you create a new data table that just has the customers that are in the top 10.&amp;nbsp; The script below generates the subset and then plots the data.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;names default to here(1);
dt=current data table();

dtSum == dt &amp;lt;&amp;lt; Summary(
	Group( :Customer ),
	Sum( :Total Dollars Ordered ),
	Freq( "None" ),
	Weight( "None" ),
	statistics column name format( "column" )
);

dtSum &amp;lt;&amp;lt; sort( by(:Total Dollars Ordered), order(descending),replace table(1));

dtSum &amp;lt;&amp;lt; select where(Row()&amp;gt;10);

dtSum &amp;lt;&amp;lt; delete rows;

dtFinal = dt&amp;lt;&amp;lt; Join(
	With( dtSum ),
	By Matching Columns( :Customer = :Customer ),
	Drop multiples( 0, 0 ),
	Include Nonmatches( 0, 0 ),
	Preserve main table order( 1 )
);

dtFinal &amp;lt;&amp;lt; Graph Builder(
	Size( 905, 603 ),
	Variables(
		X( :Total Dollars Ordered ),
		Y(
			:Customer,
			Order By( :Total Dollars Ordered, Ascending, Order Statistic( "Sum" ) )
		),
		Overlay( :Sales Organization Code )
	),
	Elements(
		Bar( X, Y, Legend( 4 ), Bar Style( "Stacked" ), Summary Statistic( "Sum" ) )
	),
	SendToReport(
		Dispatch(
			{},
			"graph title",
			TextEditBox,
			{Set Text( "Total Dollars Ordered by Customer" )}
		)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I did not have a copy of your data, so I have not completly tested the script, but I think it should work.&lt;/P&gt;
&lt;P&gt;You could also modify the script to create the order number of the summary table, and then join that back into the original data table, and use that in a local data filter to allow for selection on the order.&lt;/P&gt;
&lt;P&gt;Here is a script that is an approximation of how to create the chart using a local data filter&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;names default to here(1);
dt=current data table();

dtSum == dt &amp;lt;&amp;lt; Summary(
	Group( :Customer ),
	Sum( :Total Dollars Ordered ),
	Freq( "None" ),
	Weight( "None" ),
	statistics column name format( "column" ),
	Link to original data table( 0 )
);

dtSum &amp;lt;&amp;lt; sort( by(:Total Dollars Ordered), order(descending),replace table(1));

dtSum &amp;lt;&amp;lt; New Column("Rank", formula(Row()));
dtSum:Rank &amp;lt;&amp;lt; delete property("formula");
dtSum &amp;lt;&amp;lt; delete columns({"Total Dollars Ordered", "N Rows"})

dt&amp;lt;&amp;lt; Update(
	With( dtSum ) ,
	Match Columns( :Customer == :Customer )
);


dt &amp;lt;&amp;lt; Graph Builder(
	Size( 905, 603 ),
	Variables(
		X( :Total Dollars Ordered ),
		Y(
			:Customer,
			Order By( :Total Dollars Ordered, Ascending, Order Statistic( "Sum" ) )
		),
		Overlay( :Sales Organization Code )
	),
	Elements(
		Bar( X, Y, Legend( 4 ), Bar Style( "Stacked" ), Summary Statistic( "Sum" ) )
	),
	SendToReport(
		Dispatch(
			{},
			"graph title",
			TextEditBox,
			{Set Text( "Total Dollars Ordered by Customer" )}
		)
	),
	Local Data Filter(
		Add Filter( columns( :Rank ), Where( :Rank &amp;gt;= 1 &amp;amp; :Rank &amp;lt;= 11 ) )
);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Mar 2019 18:16:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Graph-Builder-Bar-Graph-filter-by-top-10-Sums/m-p/186762#M40522</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2019-03-13T18:16:58Z</dc:date>
    </item>
    <item>
      <title>Re: Graph Builder Bar Graph filter by top 10 Sums</title>
      <link>https://community.jmp.com/t5/Discussions/Graph-Builder-Bar-Graph-filter-by-top-10-Sums/m-p/186803#M40526</link>
      <description>&lt;P&gt;I like the 2nd approach.&amp;nbsp; The script seems to be stopping&amp;nbsp; right after the first section of code.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dtSum == dt &amp;lt;&amp;lt; Summary(
	Group( :Customer ),
	Sum( :Total Dollars Ordered ),
	Freq( "None" ),
	Weight( "None" ),
	statistics column name format( "column" ),
	Link to original data table( 0 )
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Because I'm getting a new data table but it isn't sorted and doesn't have rank. Which is the next set of JSL.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Mar 2019 19:34:10 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Graph-Builder-Bar-Graph-filter-by-top-10-Sums/m-p/186803#M40526</guid>
      <dc:creator>BSwid</dc:creator>
      <dc:date>2019-03-13T19:34:10Z</dc:date>
    </item>
    <item>
      <title>Re: Graph Builder Bar Graph filter by top 10 Sums</title>
      <link>https://community.jmp.com/t5/Discussions/Graph-Builder-Bar-Graph-filter-by-top-10-Sums/m-p/186809#M40529</link>
      <description>Okay the problem is "==", just need one "="</description>
      <pubDate>Wed, 13 Mar 2019 20:22:51 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Graph-Builder-Bar-Graph-filter-by-top-10-Sums/m-p/186809#M40529</guid>
      <dc:creator>BSwid</dc:creator>
      <dc:date>2019-03-13T20:22:51Z</dc:date>
    </item>
    <item>
      <title>Re: Graph Builder Bar Graph filter by top 10 Sums</title>
      <link>https://community.jmp.com/t5/Discussions/Graph-Builder-Bar-Graph-filter-by-top-10-Sums/m-p/186811#M40531</link>
      <description>&lt;P&gt;Oops....my error....glad you caught it!&lt;/P&gt;</description>
      <pubDate>Wed, 13 Mar 2019 20:34:28 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Graph-Builder-Bar-Graph-filter-by-top-10-Sums/m-p/186811#M40531</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2019-03-13T20:34:28Z</dc:date>
    </item>
    <item>
      <title>Re: Graph Builder Bar Graph filter by top 10 Sums</title>
      <link>https://community.jmp.com/t5/Discussions/Graph-Builder-Bar-Graph-filter-by-top-10-Sums/m-p/186813#M40533</link>
      <description>&lt;P&gt;Here's what I ended up going with.&amp;nbsp; Thank you for your help.&lt;/P&gt;&lt;P&gt;Top 20 looked nicer.&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);
dt=current data table();

//Summarize the Total Dollars Ordered by Customer
dtSum = dt &amp;lt;&amp;lt; Summary(
	Group( :Customer ),
	Sum( :Total Dollars Ordered ),
	Freq( "None" ),
	Weight( "None" ),
	statistics column name format( "column" ),
	Link to original data table( 0 )
);

//Sort the new data table
dtSum &amp;lt;&amp;lt; sort( by(:Total Dollars Ordered), order(descending),replace table(1));

//Add Customer Sales Rank
//because the data is sorted the rank is the row number
dtSum &amp;lt;&amp;lt; New Column("Customer Sales Rank", formula(Row()));
dtSum:Customer Sales Rank &amp;lt;&amp;lt; delete property("formula");
dtSum &amp;lt;&amp;lt; delete columns({"Total Dollars Ordered", "N Rows"});

//add the Customer Sales Rank back to the original data table
dt &amp;lt;&amp;lt; Update(
	With( dtSum ) ,
	Match Columns( :Customer == :Customer )
);

//close the helper table
close(dtSum);

//Create the graph, horizontal bar graph, highest sales at the top, 
dt &amp;lt;&amp;lt; Graph Builder(
	Size( 966, 804 ),
	//hide the control panel
	Show Control Panel( 0 ),
	Variables(
		X( :Total Dollars Ordered ),
		Y(
			:Customer,
			Order By( :Total Dollars Ordered, Ascending, Order Statistic( "Sum" ) )
		),
		Overlay( :Sales Organization Code )
	),
	Elements(
		Bar(
			X,
			Y,
			Legend( 4 ),
			Bar Style( "Stacked" ),
			Summary Statistic( "Sum" ),
			Label( "Label by Percent of Total Values" )
		)
	),
	Local Data Filter(
		//hide the local filer
		Close Outline(1),
		Add Filter(
			columns( :Customer Sales Rank ),
			Where( :Customer Sales Rank &amp;gt;= 1 &amp;amp; :Customer Sales Rank &amp;lt;= 20 )
		)
	),
	SendToReport(
		Dispatch(
			{},
			"graph title",
			TextEditBox,
			{Set Text( "Total Dollars Ordered by Customer" )}
		)
	)
)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Mar 2019 21:16:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Graph-Builder-Bar-Graph-filter-by-top-10-Sums/m-p/186813#M40533</guid>
      <dc:creator>BSwid</dc:creator>
      <dc:date>2019-03-13T21:16:23Z</dc:date>
    </item>
  </channel>
</rss>

