通过/失败公式如何运作?我遇到了公式返回空值的问题。
原始表是原始数据,还有一个规范表,用于根据规范表判断原始数据是否通过。我写了个JSL,请帮我看看是什么问题,谢谢。
Names Default To Here( 1 );
//raw data
dt = Data Table( "raw data001" );
dt1 = dt << subset( all rows, all columns );
//spec table
dtbz = Data Table( "Spec" );
LSL = dtbz[0, 3];
USL = dtbz[0, 4];
dtbz << New Column( "combine", formula( :Project || :Item ) );
// Create separate judgment columns for the columns to be judged
items = Design( dtbz:Item << get values(), <
<LEVELS>
0, dtbz:LSL[Loc( dtbz:combine << get as matrix(), "A" || it )[1]] <= Column( dt1, items[i] ) <= dtbz:USL[ Loc( dtbz:combine << get as matrix(), "A" || it )[1]], :Project == "B" & N Items( Loc( dtbz:combine << get as matrix(), "B" || it ) ) > 0, dtbz:LSL[Loc( dtbz:combine << get as matrix(), "B" || it )[1]] <= Column( dt1, items[i] ) <= dtbz:USL[ Loc( dtbz:combine << get as matrix(), "B" || it )[1]], :Project == "C" & N Items( Loc( dtbz:combine << get as matrix(), "C" || it ) ) > 0, dtbz:LSL[Loc( dtbz:combine << get as matrix(), "C" || it )[1]] <= Column( dt1, items[i] ) <= dtbz:USL[ Loc( dtbz:combine << get as matrix(), "C" || it )[1]], :Project == "D" & N Items( Loc( dtbz:combine << get as matrix(), "D" || it ) ) > 0, dtbz:LSL[Loc( dtbz:combine << get as matrix(), "D" || it )[1]] <= Column( dt1, items[i] ) <= dtbz:USL[ Loc( dtbz:combine << get as matrix(), "D" || it )[1]], ) ) ) );
</LEVELS>
自动化和脚本回复:通过/失败公式如何计算?这是对您的脚本的修改,我认为它简化了它,并且仍然为您提供了收益

Names Default To Here( 1 );
//raw data
dt = Data Table( "raw data001" );
dt1 = dt << subset( all rows, all columns );
//spec table
dtbz = Data Table( "Spec" );
LSL = dtbz[0, 4];
USL = dtbz[0, 5];
//dtbz << New Column( "combine", formula( :Project || :Item ) );
dtbz << New Column( "combine", character, formula( :Project || :Item ) );
// Create separate judgment columns for the columns to be judged
// items = Design( dtbz:Item << get values(), <<LEVELS> 0,
dtbz:USL[Loc( dtbz:combine << get as matrix(), "A" || it )[1]] <= Column( dt1, items[i] )
<= dtbz:USL[Loc( dtbz:combine << get as matrix(), "A" || it )[1]],
:Project == "B" & N Items( Loc( dtbz:combine << get as matrix(), "B" || it ) ) > 0,
dtbz:USL[Loc( dtbz:combine << get as matrix(), "B" || it )[1]] <= Column( dt1, items[i] )
<= dtbz:USL[Loc( dtbz:combine << get as matrix(), "B" || it )[1]],
:Project == "C" & N Items( Loc( dtbz:combine << get as matrix(), "C" || it ) ) > 0,
dtbz:USL[Loc( dtbz:combine << get as matrix(), "C" || it )[1]] <= Column( dt1, items[i] )
<= dtbz:USL[Loc( dtbz:combine << get as matrix(), "C" || it )[1]],
:Project == "D" & N Items( Loc( dtbz:combine << get as matrix(), "D" || it ) ) > 0,
dtbz:USL[Loc( dtbz:combine << get as matrix(), "D" || it )[1]] <= Column( dt1, items[i] )
<= dtbz:USL[Loc( dtbz:combine << get as matrix(), "D" || it )[1]],
)
)
);*/
Eval(
Substitute(
Expr(
dt1 << New Column( it || "—yield",
formula(
curProject = :Project;
Try( dtbzRow = (dtbz << get rows where( dtbz:Project == curProject & dtbz:item == __it__ ))[1], 0 );
If( dtbzRow > 0,
If( dtbz:LSL[dtbzRow] <= As Column( dt1, __it__ ) <= dtbz:USL[dtbzRow],
1,
0
)
);
)
)
),
Expr( __it__ ), it
)
);
);</LEVELS>
回复:通过/失败公式如何计算?非常感谢您的快速答复,它有效。
回复:通过/失败公式如何计算?你好吉姆,还有一个小问题是,当规范表中没有找到对应的USL和LSL时,应该返回null值,但是这段代码运行起来返回0。 我不知道发生了什么事。
回复:通过/失败公式如何计算?我提供的原始修改假设所有规格限制均可用。为了考虑到丢失限制的可能性,需要更改公式来处理这些情况。下面的 JSL 针对几种可能的情况进行了调整,但您可能需要添加其他情况,例如:
USL 小于 LSL
Names Default To Here( 1 );
//raw data
dt = Data Table( "raw data001" );
dt1 = dt << 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 << get values(), <<LEVELS> 0 & Is Missing( dtbz:LSL[dtbzRow] ) == 0 & Is Missing( dtbz:USL[dtbzRow] ) == 0,
If( dtbz:LSL[dtbzRow] <= As Column( dt1, __it__ ) <= dtbz:USL[dtbzRow],
1,
0
),
.
);
)
)
),
Expr( __it__ ), it
)
);
);</LEVELS>回复:通过/失败公式如何计算?谢谢,但是我有一个问题,为什么之前的代码会出现这个问题? 我看前面代码的逻辑是:如果在SPEC表中找到了,那么就判断,没有找到也没有代码,应该是空值啊,为什么还要判断呢?
回复:通过/失败公式如何计算?计算值在行之间保持不变,因此,如果第 2 行中的条件未对计算值进行更改,则为第 1 行计算的值将保持不变。
回复:通过/失败公式如何计算?谢谢! 我尝试了一下,确实在之前的代码运行下,如果在SPEC表中没有找到,它将按照上一行的dtbzRow进行查找。 明明没有找到,但是还是压了上一行的值。 我在例程公式中没有找到这一点,是否只有当我使用另一个表的查找时才会发生?
回复:通过/失败公式如何计算?JMP 中的内存变量在更改之前保持不变。下面是一个脚本,它创建一个新列和公式,在第 1 行设置变量“a”,然后在第 10 行更改它。您可以看到“a”的值直到第 10 行才更改,但仍保持在到那时为止的初始设定值。
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" ) << New Column( "test",
Numeric,
"Continuous",
Format( "Best", 12 )
);
dt:test << set formula(
If( Row() == 1, a = 1 );
If( Row() == 10, a = a + 1 );
:test = a;
);
回复:通过/失败公式如何计算?明白了,是因为如果在try语句中找不到,就不会赋值给它,导致原来的值,但是一开始的第一行就找不到了,那怎么办它分配了?
回复:通过/失败公式如何计算?我对脚本进行了注释,以使其更容易阅读。我还对 Try() 函数进行了细微更改,将其移至向 dtbzRow 提供结果。
看看这是否有助于理解
Names Default To Here( 1 );
//raw data
dt = Data Table( "raw data001" );
dt1 = dt << 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 << get values(), <<LEVELS> 0 & Is Missing( dtbz:LSL[dtbzRow] ) == 0 &
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] <= As Column( dt1, __it__ ) <= dtbz
:USL[dtbzRow],
1,
0
),
.
);
)
)
),
Expr( __it__ ), it
)
);
);</LEVELS>回复:通过/失败公式如何计算?我明白了,谢谢你的耐心!