<?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: Sort categorical variables in local data filter (not alphabetically) in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Sort-categorical-variables-in-local-data-filter-not/m-p/396268#M64698</link>
    <description>&lt;P&gt;Here is a script that uses the default Local Data Filter, along with the Value Order column property to accomplish what you are creating.&amp;nbsp; The script includes 2 methods for setting the order&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_0-1624710259312.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/33808i66DBE083CF413E48/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_0-1624710259312.png" alt="txnelson_0-1624710259312.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

// If the sorting of the default data table is not an issue this simple code will set 
// the order of the name column to the order found in the data table
/*dt &amp;lt;&amp;lt; sort( by( :age ), order( Ascending ), replace table( 1 ) );
dt:name &amp;lt;&amp;lt; set property( "value order", {Common Order( 0 ), Row Order Levels( 1 )} );*/

// The code below creates a subset of the default data when it sorts, and then sets the
// Value Order column property to the order found in the sorted data
dtSort = dt &amp;lt;&amp;lt; sort( private, by( :age ), order( Ascending ) );
sortList = dtSort:Name &amp;lt;&amp;lt; get values;
Close( dtSort, Nosave );
Eval(
	Substitute(
			Expr(
				dt:name &amp;lt;&amp;lt; set property(
					"value order",
					{Custom Order( __sList__ ), Common Order( 0 ), Numerical Order( 0 )}
				)
			),
		Expr( __sList__ ), sortList
	)
);

Bubble Plot(
	X( :weight ),
	Y( :height ),
	Sizes( :age ),
	Title Position( 0, 0 ),
	Local Data Filter(
		Add Filter(
			columns( :name ),
			Display( :name, N Items( 15 ), Find( Set Text( "" ) ) )
		)
	),
	SendToReport(
		Dispatch(
			{},
			"weight",
			ScaleBox,
			{Format( "Fixed Dec", 12, 0 ), Min( 60 ), Max( 180 ), Inc( 20 ),
			Minor Ticks( 0 )}
		),
		Dispatch(
			{},
			"height",
			ScaleBox,
			{Format( "Fixed Dec", 12, 0 ), Min( 50 ), Max( 72.5 ), Inc( 5 ),
			Minor Ticks( 1 )}
		)
	)
);


&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 26 Jun 2021 12:24:49 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2021-06-26T12:24:49Z</dc:date>
    <item>
      <title>Sort categorical variables in local data filter (not alphabetically)</title>
      <link>https://community.jmp.com/t5/Discussions/Sort-categorical-variables-in-local-data-filter-not/m-p/396254#M64697</link>
      <description>&lt;P&gt;I notice that the Local Data Filter for categorical variables shows them in alphabetic order.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There is an option to order them by count, but I was after the option of sorting them by other variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my case, I have a specific list I want to use as an order, but not sure how to do it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a simpler way than the following?&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
New Window( "Selection Filter",
	Data Filter Context Box(
		H List Box(
			dfsb = Data Filter Source Box(
				Graph Builder(
					Size( 419, 533 ),
					Show Control Panel( 0 ),
					Show Legend( 0 ),
					Variables( Y( :name, Order By( :age, Ascending, Order Statistic( "Mean" ) ) ) ),
					Elements( Bar( Y, Legend( 3 ) ) ),
					SendToReport(
						Dispatch(
							{},
							"Graph Builder",
							OutlineBox,
							{Set Title( "Filter" ), Image Export Display( Normal )}
						)
					)
				);
			),
			Platform(
				Current Data Table(),
				Bubble Plot( X( :weight ), Y( :height ), Sizes( :age ), Title Position( 0, 0 ) )
			)
		)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jun 2023 11:15:30 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Sort-categorical-variables-in-local-data-filter-not/m-p/396254#M64697</guid>
      <dc:creator>FN</dc:creator>
      <dc:date>2023-06-11T11:15:30Z</dc:date>
    </item>
    <item>
      <title>Re: Sort categorical variables in local data filter (not alphabetically)</title>
      <link>https://community.jmp.com/t5/Discussions/Sort-categorical-variables-in-local-data-filter-not/m-p/396268#M64698</link>
      <description>&lt;P&gt;Here is a script that uses the default Local Data Filter, along with the Value Order column property to accomplish what you are creating.&amp;nbsp; The script includes 2 methods for setting the order&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_0-1624710259312.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/33808i66DBE083CF413E48/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_0-1624710259312.png" alt="txnelson_0-1624710259312.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

// If the sorting of the default data table is not an issue this simple code will set 
// the order of the name column to the order found in the data table
/*dt &amp;lt;&amp;lt; sort( by( :age ), order( Ascending ), replace table( 1 ) );
dt:name &amp;lt;&amp;lt; set property( "value order", {Common Order( 0 ), Row Order Levels( 1 )} );*/

// The code below creates a subset of the default data when it sorts, and then sets the
// Value Order column property to the order found in the sorted data
dtSort = dt &amp;lt;&amp;lt; sort( private, by( :age ), order( Ascending ) );
sortList = dtSort:Name &amp;lt;&amp;lt; get values;
Close( dtSort, Nosave );
Eval(
	Substitute(
			Expr(
				dt:name &amp;lt;&amp;lt; set property(
					"value order",
					{Custom Order( __sList__ ), Common Order( 0 ), Numerical Order( 0 )}
				)
			),
		Expr( __sList__ ), sortList
	)
);

Bubble Plot(
	X( :weight ),
	Y( :height ),
	Sizes( :age ),
	Title Position( 0, 0 ),
	Local Data Filter(
		Add Filter(
			columns( :name ),
			Display( :name, N Items( 15 ), Find( Set Text( "" ) ) )
		)
	),
	SendToReport(
		Dispatch(
			{},
			"weight",
			ScaleBox,
			{Format( "Fixed Dec", 12, 0 ), Min( 60 ), Max( 180 ), Inc( 20 ),
			Minor Ticks( 0 )}
		),
		Dispatch(
			{},
			"height",
			ScaleBox,
			{Format( "Fixed Dec", 12, 0 ), Min( 50 ), Max( 72.5 ), Inc( 5 ),
			Minor Ticks( 1 )}
		)
	)
);


&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 26 Jun 2021 12:24:49 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Sort-categorical-variables-in-local-data-filter-not/m-p/396268#M64698</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2021-06-26T12:24:49Z</dc:date>
    </item>
  </channel>
</rss>

