<?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 the pass/fail formula works？ in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-the-pass-fail-formula-works/m-p/653493#M84289</link>
    <description>&lt;P&gt;Memory variables in JMP remain persistent until changed.&amp;nbsp; Here is a script that creates a new column and formula that sets a variable "a" on row 1, and then changes it at row 10.&amp;nbsp; You can see the value of "a" does not change until row 10, but remains at the initial set value until then.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

dt = 
// Open Data Table: Big Class.jmp
// → Data Table( "Big Class" )
Open( "$SAMPLE_DATA/Big Class.jmp" );


// New column: Column 6
Data Table( "Big Class" ) &amp;lt;&amp;lt; New Column( "test",
	Numeric,
	"Continuous",
	Format( "Best", 12 )
);

dt:test &amp;lt;&amp;lt; set formula(
	If( Row() == 1, a = 1 );
	If( Row() == 10, a = a + 1 );
	:test = a;
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 28 Jun 2023 01:41:01 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2023-06-28T01:41:01Z</dc:date>
    <item>
      <title>How the pass/fail formula works？</title>
      <link>https://community.jmp.com/t5/Discussions/How-the-pass-fail-formula-works/m-p/652919#M84260</link>
      <description>&lt;P&gt;I'm having a problem where the formulas are returning null values.&lt;BR /&gt;The raw table is the raw data and there is a specification table, which is used to determine whether the raw data passes or fails according to the specification table. I have written a JSL, please help me to see what the problem is, thanks.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
//raw data
dt = Data Table( "raw data001" );

dt1 = dt &amp;lt;&amp;lt; subset( all rows, all columns );

//spec table

dtbz = Data Table( "Spec" );
LSL = dtbz[0, 3];
USL = dtbz[0, 4];
dtbz &amp;lt;&amp;lt; New Column( "combine", formula( :Project || :Item ) );

// Create separate judgment columns for the columns to be judged
items = Design( dtbz:Item &amp;lt;&amp;lt; get values(), &amp;lt;&amp;lt;levels )[2];



// new column to justify the pass/no pass


For( i = 1, i &amp;lt;= N Items( items ), i++,
	it = items[i];
	
	dt1 &amp;lt;&amp;lt; New Column( it || "—pass/no pass",
		formula(
					
			If(
				:Project == "A" &amp;amp; N Items( Loc( dtbz:combine &amp;lt;&amp;lt; get as matrix(), "A" || it ) ) &amp;gt; 0,
					dtbz:LSL[Loc( dtbz:combine &amp;lt;&amp;lt; get as matrix(), "A" || it )[1]] &amp;lt;= Column( dt1, items[i] ) &amp;lt;= dtbz:USL[
					Loc( dtbz:combine &amp;lt;&amp;lt; get as matrix(), "A" || it )[1]], 	
					
				:Project == "B" &amp;amp; N Items( Loc( dtbz:combine &amp;lt;&amp;lt; get as matrix(), "B" || it ) ) &amp;gt; 0,
					dtbz:LSL[Loc( dtbz:combine &amp;lt;&amp;lt; get as matrix(), "B" || it )[1]] &amp;lt;= Column( dt1, items[i] ) &amp;lt;= dtbz:USL[
					Loc( dtbz:combine &amp;lt;&amp;lt; get as matrix(), "B" || it )[1]], 	
					
				:Project == "C" &amp;amp; N Items( Loc( dtbz:combine &amp;lt;&amp;lt; get as matrix(), "C" || it ) ) &amp;gt; 0,
					dtbz:LSL[Loc( dtbz:combine &amp;lt;&amp;lt; get as matrix(), "C" || it )[1]] &amp;lt;= Column( dt1, items[i] ) &amp;lt;= dtbz:USL[
					Loc( dtbz:combine &amp;lt;&amp;lt; get as matrix(), "C" || it )[1]], 	
					
				:Project == "D" &amp;amp; N Items( Loc( dtbz:combine &amp;lt;&amp;lt; get as matrix(), "D" || it ) ) &amp;gt; 0,
					dtbz:LSL[Loc( dtbz:combine &amp;lt;&amp;lt; get as matrix(), "D" || it )[1]] &amp;lt;= Column( dt1, items[i] ) &amp;lt;= dtbz:USL[
					Loc( dtbz:combine &amp;lt;&amp;lt; get as matrix(), "D" || it )[1]], 	
					
						
						
			)
		)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Jul 2025 19:55:47 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-the-pass-fail-formula-works/m-p/652919#M84260</guid>
      <dc:creator>lehaofeng</dc:creator>
      <dc:date>2025-07-01T19:55:47Z</dc:date>
    </item>
    <item>
      <title>Re: How the pass/fail formula works？</title>
      <link>https://community.jmp.com/t5/Discussions/How-the-pass-fail-formula-works/m-p/652961#M84261</link>
      <description>&lt;P&gt;Here is a rework of your script that I think simplifies it, and still provides you with your yields&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_0-1687847223187.png" style="width: 697px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/54189iD3216018BE89A50D/image-dimensions/697x469?v=v2" width="697" height="469" role="button" title="txnelson_0-1687847223187.png" alt="txnelson_0-1687847223187.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
//raw data
dt = Data Table( "raw data001" );

dt1 = dt &amp;lt;&amp;lt; subset( all rows, all columns );

//spec table

dtbz = Data Table( "Spec" );
LSL = dtbz[0, 4];
USL = dtbz[0, 5];
//dtbz &amp;lt;&amp;lt; New Column( "combine", formula( :Project || :Item ) );
dtbz &amp;lt;&amp;lt; New Column( "combine", character, formula( :Project || :Item ) );

// Create separate judgment columns for the columns to be judged
// items = Design( dtbz:Item &amp;lt;&amp;lt; get values(), &amp;lt;&amp;lt;levels )[2];
// items = dt &amp;lt;&amp;lt; get column names( string, numeric );
Summarize( dtbz, items = by( :item ) );

// new column to justify the pass/no pass

For( i = 1, i &amp;lt;= N Items( items ), i++,
	it = items[i];
	
/*	dt1 &amp;lt;&amp;lt; New Column( it || "—yield",
		formula(
					
			If(
				:Project == "A" &amp;amp; N Items( Loc( dtbz:combine &amp;lt;&amp;lt; get as matrix(), "A" || it ) ) &amp;gt; 0,
					dtbz:USL[Loc( dtbz:combine &amp;lt;&amp;lt; get as matrix(), "A" || it )[1]] &amp;lt;= Column( dt1, items[i] )
					 &amp;lt;= dtbz:USL[Loc( dtbz:combine &amp;lt;&amp;lt; get as matrix(), "A" || it )[1]], 	
					
				:Project == "B" &amp;amp; N Items( Loc( dtbz:combine &amp;lt;&amp;lt; get as matrix(), "B" || it ) ) &amp;gt; 0,
					dtbz:USL[Loc( dtbz:combine &amp;lt;&amp;lt; get as matrix(), "B" || it )[1]] &amp;lt;= Column( dt1, items[i] )
					 &amp;lt;= dtbz:USL[Loc( dtbz:combine &amp;lt;&amp;lt; get as matrix(), "B" || it )[1]], 	
					
				:Project == "C" &amp;amp; N Items( Loc( dtbz:combine &amp;lt;&amp;lt; get as matrix(), "C" || it ) ) &amp;gt; 0,
					dtbz:USL[Loc( dtbz:combine &amp;lt;&amp;lt; get as matrix(), "C" || it )[1]] &amp;lt;= Column( dt1, items[i] )
					 &amp;lt;= dtbz:USL[Loc( dtbz:combine &amp;lt;&amp;lt; get as matrix(), "C" || it )[1]], 	
					
				:Project == "D" &amp;amp; N Items( Loc( dtbz:combine &amp;lt;&amp;lt; get as matrix(), "D" || it ) ) &amp;gt; 0,
					dtbz:USL[Loc( dtbz:combine &amp;lt;&amp;lt; get as matrix(), "D" || it )[1]] &amp;lt;= Column( dt1, items[i] )
					 &amp;lt;= dtbz:USL[Loc( dtbz:combine &amp;lt;&amp;lt; get as matrix(), "D" || it )[1]], 			
			)
		)
	);*/


	Eval(
		Substitute(
				Expr(
					dt1 &amp;lt;&amp;lt; New Column( it || "—yield",
						formula(
							curProject = :Project;
							Try( dtbzRow = (dtbz &amp;lt;&amp;lt; get rows where( dtbz:Project == curProject &amp;amp; dtbz:item == __it__ ))[1], 0 );
							If( dtbzRow &amp;gt; 0,
								If( dtbz:LSL[dtbzRow] &amp;lt;= As Column( dt1, __it__ ) &amp;lt;= dtbz:USL[dtbzRow],
									1,
									0
								)
							);
						)
					)
				),
			Expr( __it__ ), it
		)
	);
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Jun 2023 06:27:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-the-pass-fail-formula-works/m-p/652961#M84261</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2023-06-27T06:27:58Z</dc:date>
    </item>
    <item>
      <title>Re: How the pass/fail formula works？</title>
      <link>https://community.jmp.com/t5/Discussions/How-the-pass-fail-formula-works/m-p/652966#M84262</link>
      <description>&lt;P&gt;Thank you very much for your quick answer, it works.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Jun 2023 06:48:44 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-the-pass-fail-formula-works/m-p/652966#M84262</guid>
      <dc:creator>lehaofeng</dc:creator>
      <dc:date>2023-06-27T06:48:44Z</dc:date>
    </item>
    <item>
      <title>Re: How the pass/fail formula works？</title>
      <link>https://community.jmp.com/t5/Discussions/How-the-pass-fail-formula-works/m-p/652971#M84263</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;Jim&lt;/SPAN&gt;， another small problem is that when the corresponding USL and LSL are not found in the specification table, the null value should be returned, but this code runs and returns 0. I don't know what is going on.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Jun 2023 08:03:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-the-pass-fail-formula-works/m-p/652971#M84263</guid>
      <dc:creator>lehaofeng</dc:creator>
      <dc:date>2023-06-27T08:03:06Z</dc:date>
    </item>
    <item>
      <title>Re: How the pass/fail formula works？</title>
      <link>https://community.jmp.com/t5/Discussions/How-the-pass-fail-formula-works/m-p/653100#M84271</link>
      <description>&lt;P&gt;The original modification I provided assumed that all Spec Limits would be available.&amp;nbsp; To allow for the potential of missing Limits, the formulas need to be changed to handle those cases.&amp;nbsp; The JSL below adjusts for a couple of possible cases, but you may need to add others, like:&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;The USL is less than the LSL&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
//raw data
dt = Data Table( "raw data001" );

dt1 = dt &amp;lt;&amp;lt; subset( all rows, all columns );

//spec table

dtbz = Data Table( "Spec" );

// Create separate judgment columns for the columns to be judged
// items = Design( dtbz:Item &amp;lt;&amp;lt; get values(), &amp;lt;&amp;lt;levels )[2];
// items = dt &amp;lt;&amp;lt; get column names( string, numeric );
Summarize( dtbz, items = by( :item ) );

// new column to justify the pass/no pass

For( i = 1, i &amp;lt;= N Items( items ), i++,
	it = items[i];

	Eval(
		Substitute(
				Expr(
					dt1 &amp;lt;&amp;lt; New Column( it || "—yield",
						formula(
							curProject = :Project;
							dtbzRow = .;
							Try( dtbzRow = (dtbz &amp;lt;&amp;lt; get rows where( dtbz:Project == curProject &amp;amp; dtbz:item == __it__ ))[1], 0 );
							Show( :project, dtbzRow );
							If( dtbzRow &amp;gt; 0 &amp;amp; Is Missing( dtbz:LSL[dtbzRow] ) == 0 &amp;amp; Is Missing( dtbz:USL[dtbzRow] ) == 0,
								If( dtbz:LSL[dtbzRow] &amp;lt;= As Column( dt1, __it__ ) &amp;lt;= dtbz:USL[dtbzRow],
									1,
									0
								),
								.
							);
						)
					)
				),
			Expr( __it__ ), it
		)
	);
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 27 Jun 2023 13:30:15 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-the-pass-fail-formula-works/m-p/653100#M84271</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2023-06-27T13:30:15Z</dc:date>
    </item>
    <item>
      <title>Re: How the pass/fail formula works？</title>
      <link>https://community.jmp.com/t5/Discussions/How-the-pass-fail-formula-works/m-p/653106#M84272</link>
      <description>&lt;P&gt;Thank you, but I have a question, why did the previous code have this problem? I see the logic of the previous code is: if found in the SPEC table, then the judgment, not found and there is no code, should be the empty value ah, why is still judging it?&lt;/P&gt;</description>
      <pubDate>Tue, 27 Jun 2023 13:36:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-the-pass-fail-formula-works/m-p/653106#M84272</guid>
      <dc:creator>lehaofeng</dc:creator>
      <dc:date>2023-06-27T13:36:09Z</dc:date>
    </item>
    <item>
      <title>Re: How the pass/fail formula works？</title>
      <link>https://community.jmp.com/t5/Discussions/How-the-pass-fail-formula-works/m-p/653132#M84273</link>
      <description>&lt;P&gt;Calculated values persist from row to row, so if a condition in row 2 does not make a change to the calculated value, then the value that was calculated for row 1 remans unchanged.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Jun 2023 14:05:25 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-the-pass-fail-formula-works/m-p/653132#M84273</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2023-06-27T14:05:25Z</dc:date>
    </item>
    <item>
      <title>Re: How the pass/fail formula works？</title>
      <link>https://community.jmp.com/t5/Discussions/How-the-pass-fail-formula-works/m-p/653492#M84288</link>
      <description>&lt;P&gt;Thanks! I tried it and indeed under the previous code run, if it is not found in the SPEC table, it will go by the dtbzRow of the previous row. It's clearly not found, but it still presses the value of the previous row. I don't find this in the routine formulas, is it only happening when I use a lookup of another table?&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jun 2023 01:26:53 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-the-pass-fail-formula-works/m-p/653492#M84288</guid>
      <dc:creator>lehaofeng</dc:creator>
      <dc:date>2023-06-28T01:26:53Z</dc:date>
    </item>
    <item>
      <title>Re: How the pass/fail formula works？</title>
      <link>https://community.jmp.com/t5/Discussions/How-the-pass-fail-formula-works/m-p/653493#M84289</link>
      <description>&lt;P&gt;Memory variables in JMP remain persistent until changed.&amp;nbsp; Here is a script that creates a new column and formula that sets a variable "a" on row 1, and then changes it at row 10.&amp;nbsp; You can see the value of "a" does not change until row 10, but remains at the initial set value until then.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

dt = 
// Open Data Table: Big Class.jmp
// → Data Table( "Big Class" )
Open( "$SAMPLE_DATA/Big Class.jmp" );


// New column: Column 6
Data Table( "Big Class" ) &amp;lt;&amp;lt; New Column( "test",
	Numeric,
	"Continuous",
	Format( "Best", 12 )
);

dt:test &amp;lt;&amp;lt; set formula(
	If( Row() == 1, a = 1 );
	If( Row() == 10, a = a + 1 );
	:test = a;
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Jun 2023 01:41:01 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-the-pass-fail-formula-works/m-p/653493#M84289</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2023-06-28T01:41:01Z</dc:date>
    </item>
    <item>
      <title>Re: How the pass/fail formula works？</title>
      <link>https://community.jmp.com/t5/Discussions/How-the-pass-fail-formula-works/m-p/653494#M84290</link>
      <description>&lt;P&gt;I see, it's because if it can't be found in the try statement, it won't be assigned to it, resulting in the original value, but it can't be found in the first line at the beginning, so how is it assigned?&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jun 2023 01:41:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-the-pass-fail-formula-works/m-p/653494#M84290</guid>
      <dc:creator>lehaofeng</dc:creator>
      <dc:date>2023-06-28T01:41:12Z</dc:date>
    </item>
    <item>
      <title>Re: How the pass/fail formula works？</title>
      <link>https://community.jmp.com/t5/Discussions/How-the-pass-fail-formula-works/m-p/653513#M84292</link>
      <description>&lt;P&gt;I annotated the script in an effort to make the reading of it easier.&amp;nbsp; I also made a minor change to the Try() function, moving it to providing a result to dtbzRow.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See if this helps in the underastanding&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
//raw data
dt = Data Table( "raw data001" );

dt1 = dt &amp;lt;&amp;lt; subset( all rows, all columns );

//spec table

dtbz = Data Table( "Spec" );

// Create separate judgment columns for the columns to be judged
// items = Design( dtbz:Item &amp;lt;&amp;lt; get values(), &amp;lt;&amp;lt;levels )[2];
// items = dt &amp;lt;&amp;lt; get column names( string, numeric );
Summarize( dtbz, items = by( :item ) );

// new column to justify the pass/no pass

For( i = 1, i &amp;lt;= N Items( items ), i++,
	it = items[i];

	Eval(
		Substitute(
				Expr(
					dt1 &amp;lt;&amp;lt; New Column( it || "—yield",
						formula(
							curProject = :Project;  // Get the value of the current row
							                        // in the raw data table
							dtbzRow = .;  // dtbzRow is the row in the spec table where
							              // the spec limits are for the current Project
							              // and the current Item  Initialize it to 
							              // a missing value so any previous value is
							              // removed
							// Set the dtbzRow value to the spec table row where the
							// limits for the Project and Item are found.
							// If no such row is in the spec table, set the value
							// to 0
							dtbzRow = Try(
								(dtbz &amp;lt;&amp;lt; get rows where(
									dtbz:Project == curProject &amp;amp; dtbz:item == __it__
								))[1],
								0
							);
							
							// If a spec row is found, and there are both USL and LSL
							// limits then set the yield value.  If not found the 
							// yield value returned is a missing value
							If(
								dtbzRow &amp;gt; 0 &amp;amp; Is Missing( dtbz:LSL[dtbzRow] ) == 0 &amp;amp;
								Is Missing( dtbz:USL[dtbzRow] ) == 0,
								// If the column's value is between the LSL and USL
								// the value is set to 1, if outside one of the 
								// limits it is set to 0 
								If(
									dtbz:LSL[dtbzRow] &amp;lt;= As Column( dt1, __it__ ) &amp;lt;= dtbz
									:USL[dtbzRow],
									1,
									0
								),
								.
							);
						)
					)
				),
			Expr( __it__ ), it
		)
	);
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Jun 2023 02:36:57 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-the-pass-fail-formula-works/m-p/653513#M84292</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2023-06-28T02:36:57Z</dc:date>
    </item>
    <item>
      <title>Re: How the pass/fail formula works？</title>
      <link>https://community.jmp.com/t5/Discussions/How-the-pass-fail-formula-works/m-p/653516#M84293</link>
      <description>&lt;P&gt;I understand, thanks for your patience!&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jun 2023 02:39:56 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-the-pass-fail-formula-works/m-p/653516#M84293</guid>
      <dc:creator>lehaofeng</dc:creator>
      <dc:date>2023-06-28T02:39:56Z</dc:date>
    </item>
  </channel>
</rss>

