<?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: JMP doesn't recognize my spec limits when column name is a variable in my user-defined function (JMP 17) in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/JMP-doesn-t-recognize-my-spec-limits-when-column-name-is-a/m-p/762146#M94079</link>
    <description>&lt;P&gt;Here is a list of tricks to make a JSL expression work:&lt;BR /&gt;&lt;LI-MESSAGE title="Expression Handling in JMP: Tipps and Trapdoors" uid="747728" url="https://community.jmp.com/t5/Discussions/Expression-Handling-in-JMP-Tipps-and-Trapdoors/m-p/747728#U747728" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-forum-thread lia-fa-icon lia-fa-forum lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hints:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;most of the platforms accept the column name (= string, &lt;FONT face="courier new,courier"&gt;"Flight"&lt;/FONT&gt;) in addition the column name (=reference, &lt;FONT face="courier new,courier"&gt;:Flight&lt;/FONT&gt;) :)&lt;/img&gt;&lt;BR /&gt;so the only trick that we need: get the variable replaced by the column name (string).&lt;BR /&gt;The problem: for most of the cases Jmp doesn't evaluate an argument before calling the function.&lt;P&gt;So, if you put &lt;FONT face="courier new,courier"&gt;Eval()&lt;/FONT&gt;around the function argument, it won't help to evaluate it.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;-&amp;gt; Wrap everything in an&amp;nbsp;&lt;FONT face="courier new,courier"&gt;Eval(Eval Expr(())&lt;/FONT&gt; and replace your &lt;FONT face="courier new,courier"&gt;Eval()&lt;/FONT&gt;s with &lt;FONT face="courier new,courier"&gt;Expr()&lt;/FONT&gt;s&lt;BR /&gt;... to tell Jmp to evaluate them first.&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;capability_chart = function({variable, low, up},
		
		Eval Expr(Process Capability(
				Process Variables( Expr(variable), // select column for data
				Spec Limits( Expr(variable)(LSL( low ), /*Target( 30 ),*/ USL( up )) ),		
				Individual Detail Reports( 1 ),
				Capability Box Plots( 0 ),
				Goal Plot( 0 ),
				Capability Index Plot( 0 ),
				Process Performance Plot( 0 ) // hide unnecessary info

			))
		));
		
capability_chart("Flight", 0, 10)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but the&amp;nbsp;&lt;FONT face="courier new,courier"&gt;Spec Limits("Flight"(LSL( low ), Target( . ), USL( up )) )&lt;/FONT&gt; doesn't work, it is converted to&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Spec Limits( :Flight &amp;lt;&amp;lt; {LSL( low ), Target( .), USL( up )} )&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;So, let's try the trick with &lt;FONT face="courier new,courier"&gt;Name Expr(As column(column name)):&lt;/FONT&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Spec Limits(Expr(Name Expr(As column(variable)))(LSL( low ), Target( .), USL( up )) ),	&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;... and again, we get:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Spec Limits( :Flight &amp;lt;&amp;lt; {LSL( low ), Target( .), USL( up )} )&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;wow! ... and arg!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, let's use Plan B: which always works: use &lt;FONT face="courier new,courier"&gt;Eval(Substitute())&lt;BR /&gt;&lt;/FONT&gt;The original idea: in combination with &lt;FONT face="courier new,courier"&gt;Name Expr(As column(column_name))&lt;/FONT&gt;as the replacement expression&lt;BR /&gt;... but almost surprisingly, it even works with the bare string (!):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;capability_chart = function({variable, low, up},
		
		Eval(Substitute(Expr(Process Capability(
				Process Variables( _var_ ), // select column for data
				Spec Limits( _var_(LSL( low ), /*Target( 30 ),*/ USL( up )) ),		
				Individual Detail Reports( 1 ),
				Capability Box Plots( 0 ),
				Goal Plot( 0 ),
				Capability Index Plot( 0 ),
				Process Performance Plot( 0 ) // hide unnecessary info
			)),Expr(_var_), variable
		)));
		
capability_chart("Flight", 0, 10)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 01 Jun 2024 09:28:06 GMT</pubDate>
    <dc:creator>hogi</dc:creator>
    <dc:date>2024-06-01T09:28:06Z</dc:date>
    <item>
      <title>JMP doesn't recognize my spec limits when column name is a variable in my user-defined function (JMP 17)</title>
      <link>https://community.jmp.com/t5/Discussions/JMP-doesn-t-recognize-my-spec-limits-when-column-name-is-a/m-p/762138#M94078</link>
      <description>&lt;P&gt;I currently have a script that creates control and process capability charts for a variety of variables, puts it in a journal, and then saves the journal as a pdf. The problem is, my script is 5000 lines long and runs slower than molasses in a freezer. So I thought it would make more sense to define a function for each type of chart that I build and stitch them together that way. I successfully created functions for the control charts, but I can't get the process capability chart to work.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is a script that uses the Airport sample data (attached) to create a chart that looks like the one I'm trying to make:&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Process Capability( 		
				Process Variables( :Flight ), // select column for data
				Spec Limits( :Flight( LSL( 0 ), /*Target( 30 ),*/ USL( 20 ) ) ),		//Spec limits, dont need target
				Individual Detail Reports( 1 ),
				Capability Box Plots( 0 ),
				Goal Plot( 0 ),
				Capability Index Plot( 0 ),
				Process Performance Plot( 0 ), // hide unnecessary info
				{:Flight &amp;lt;&amp;lt; Process Capability Analysis(
					Overall Sigma Capability( 1 ),
					Within Sigma Capability( 1 ),
					Histogram( 1, Show Target( 1 ), Show Within Sigma Density( 1 ), Show Overall Sigma Density( 1 ) )
				)},
				
				);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I would like to define a function with the column name as an input. Here is what I have so far:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;capability_chart = function({variable, low, up},
		
		Process Capability(
				Process Variables( eval(variable) ), // select column for data
				Spec Limits( eval(variable)(LSL( low ), /*Target( 30 ),*/ USL( up )) ),		
				Individual Detail Reports( 1 ),
				Capability Box Plots( 0 ),
				Goal Plot( 0 ),
				Capability Index Plot( 0 ),
				Process Performance Plot( 0 ), // hide unnecessary info
				{column(dt, element) &amp;lt;&amp;lt; Process Capability Analysis(
					Overall Sigma Capability( 1 ),
					Within Sigma Capability( 1 ),
					Histogram( 1, Show Target( 1 ), Show Within Sigma Density( 1 ), Show Overall Sigma Density( 1 ) )
				)}
			)
		);
		
capability_chart("Flight", 0, 10)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;When I run this, a window pops up prompting me for spec limits. I want my script to automatically populate spec limits. I've also tried using column() and ascolumn() instead of eval() in the spec limits line but they did the same thing. Ideally, I wouldn't have to create a spec table or add spec limits as a column property but I can do that if there isn't another way. I also don't want to loop through all the columns and create a bunch of process capability charts because there's an existing format for the report that would be confusing to change. Any help is appreciated.&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 31 May 2024 16:52:30 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JMP-doesn-t-recognize-my-spec-limits-when-column-name-is-a/m-p/762138#M94078</guid>
      <dc:creator>lemonses</dc:creator>
      <dc:date>2024-05-31T16:52:30Z</dc:date>
    </item>
    <item>
      <title>Re: JMP doesn't recognize my spec limits when column name is a variable in my user-defined function (JMP 17)</title>
      <link>https://community.jmp.com/t5/Discussions/JMP-doesn-t-recognize-my-spec-limits-when-column-name-is-a/m-p/762146#M94079</link>
      <description>&lt;P&gt;Here is a list of tricks to make a JSL expression work:&lt;BR /&gt;&lt;LI-MESSAGE title="Expression Handling in JMP: Tipps and Trapdoors" uid="747728" url="https://community.jmp.com/t5/Discussions/Expression-Handling-in-JMP-Tipps-and-Trapdoors/m-p/747728#U747728" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-forum-thread lia-fa-icon lia-fa-forum lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hints:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;most of the platforms accept the column name (= string, &lt;FONT face="courier new,courier"&gt;"Flight"&lt;/FONT&gt;) in addition the column name (=reference, &lt;FONT face="courier new,courier"&gt;:Flight&lt;/FONT&gt;) :)&lt;/img&gt;&lt;BR /&gt;so the only trick that we need: get the variable replaced by the column name (string).&lt;BR /&gt;The problem: for most of the cases Jmp doesn't evaluate an argument before calling the function.&lt;P&gt;So, if you put &lt;FONT face="courier new,courier"&gt;Eval()&lt;/FONT&gt;around the function argument, it won't help to evaluate it.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;-&amp;gt; Wrap everything in an&amp;nbsp;&lt;FONT face="courier new,courier"&gt;Eval(Eval Expr(())&lt;/FONT&gt; and replace your &lt;FONT face="courier new,courier"&gt;Eval()&lt;/FONT&gt;s with &lt;FONT face="courier new,courier"&gt;Expr()&lt;/FONT&gt;s&lt;BR /&gt;... to tell Jmp to evaluate them first.&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;capability_chart = function({variable, low, up},
		
		Eval Expr(Process Capability(
				Process Variables( Expr(variable), // select column for data
				Spec Limits( Expr(variable)(LSL( low ), /*Target( 30 ),*/ USL( up )) ),		
				Individual Detail Reports( 1 ),
				Capability Box Plots( 0 ),
				Goal Plot( 0 ),
				Capability Index Plot( 0 ),
				Process Performance Plot( 0 ) // hide unnecessary info

			))
		));
		
capability_chart("Flight", 0, 10)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but the&amp;nbsp;&lt;FONT face="courier new,courier"&gt;Spec Limits("Flight"(LSL( low ), Target( . ), USL( up )) )&lt;/FONT&gt; doesn't work, it is converted to&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Spec Limits( :Flight &amp;lt;&amp;lt; {LSL( low ), Target( .), USL( up )} )&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;So, let's try the trick with &lt;FONT face="courier new,courier"&gt;Name Expr(As column(column name)):&lt;/FONT&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Spec Limits(Expr(Name Expr(As column(variable)))(LSL( low ), Target( .), USL( up )) ),	&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;... and again, we get:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Spec Limits( :Flight &amp;lt;&amp;lt; {LSL( low ), Target( .), USL( up )} )&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;wow! ... and arg!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, let's use Plan B: which always works: use &lt;FONT face="courier new,courier"&gt;Eval(Substitute())&lt;BR /&gt;&lt;/FONT&gt;The original idea: in combination with &lt;FONT face="courier new,courier"&gt;Name Expr(As column(column_name))&lt;/FONT&gt;as the replacement expression&lt;BR /&gt;... but almost surprisingly, it even works with the bare string (!):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;capability_chart = function({variable, low, up},
		
		Eval(Substitute(Expr(Process Capability(
				Process Variables( _var_ ), // select column for data
				Spec Limits( _var_(LSL( low ), /*Target( 30 ),*/ USL( up )) ),		
				Individual Detail Reports( 1 ),
				Capability Box Plots( 0 ),
				Goal Plot( 0 ),
				Capability Index Plot( 0 ),
				Process Performance Plot( 0 ) // hide unnecessary info
			)),Expr(_var_), variable
		)));
		
capability_chart("Flight", 0, 10)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Jun 2024 09:28:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JMP-doesn-t-recognize-my-spec-limits-when-column-name-is-a/m-p/762146#M94079</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2024-06-01T09:28:06Z</dc:date>
    </item>
    <item>
      <title>Re: JMP doesn't recognize my spec limits when column name is a variable in my user-defined function (JMP 17)</title>
      <link>https://community.jmp.com/t5/Discussions/JMP-doesn-t-recognize-my-spec-limits-when-column-name-is-a/m-p/762152#M94080</link>
      <description>&lt;P&gt;If you just need Process Capability for one column at the time I would use Distribution Platform in cases like this&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

capability_chart = function({dt, colname, lowlimit, highlimit}, {Default Local},
	dist = dt &amp;lt;&amp;lt; Distribution(
		Continuous Distribution(
			Column(:Flight),
			Quantiles(0),
			Summary Statistics(0),
			Histogram(0),
			Vertical(0),
			Outlier Box Plot(0),
			Process Capability(LSL(lowlimit), Target(.), USL(highlimit))
		)
	);
	return(dist);
);

dt = Open("$SAMPLE_DATA/Quality Control/Airport.jmp");
pc = capability_chart(dt, "Flight", 0, 10);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You will end up with a bit different report due to outline boxes, but those can be "hidden" if needed (or just take the Outline Box you are interested in to you report)&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1717177178809.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/64700i9F22400D4DD4D88D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1717177178809.png" alt="jthi_0-1717177178809.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 31 May 2024 17:39:49 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JMP-doesn-t-recognize-my-spec-limits-when-column-name-is-a/m-p/762152#M94080</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-05-31T17:39:49Z</dc:date>
    </item>
  </channel>
</rss>

