を受け取りました議論したい公式ほぼ3年前から@txnelsonそれ以来、それを手放すことはなく、今まで何度も考え、徐々にスクリプトをより真剣に理解するようになりました。 その間、公式が私を救ってくれましたたくさん時間の。
以下の例では、同じ数式が 3 回追加されますが、毎回少しずつ変化させられます。 ここで説明したい問題は、新しく追加された数式列を含むテーブルのテーブル スクリプトをコピーして実行するときにスローされるさまざまなエラー メッセージです。
Names Default To Here( 1 );
// first, we need an example table
dt = New Table( "ExampleTable",
Add Rows( 24 ),
New Column( "BatchId",
Character,
"Nominal",
Set Values(
{"A", "A", "A", "A", "A", "A", "B", "B", "B", "C", "C", "C", "D", "D",
"D", "E", "E", "E", "F", "F", "F", "G", "G", "G"}
)
),
New Column( "StorageCondition",
Character,
"Nominal",
Set Values(
{"25°C/60%RH", "25°C/60%RH", "25°C/60%RH", "5°C", "5°C", "5°C",
"25°C/60%RH", "25°C/60%RH", "25°C/60%RH", "25°C/60%RH", "25°C/60%RH",
"25°C/60%RH", "25°C/60%RH", "25°C/60%RH", "25°C/60%RH", "25°C/60%RH",
"25°C/60%RH", "25°C/60%RH", "25°C/60%RH", "25°C/60%RH", "25°C/60%RH",
"25°C/60%RH", "25°C/60%RH", "25°C/60%RH"}
)
),
New Column( "Time",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values(
[0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2]
)
),
New Column( "QcParameter",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values(
[0.2, 0.3, 0.4, 0.2, 0.21, 0.22, 0.3, 0.9, 1.2, ., 0.2, 0.4, 0.1, ., 0.1,
0, 0, 0, 0.1, 0, 0, 0, 0.1, 0]
)
)
);
// adding formula column via approach nr. 1<BR />// this adds the formula alright, but when copying and executing the resulting table script will leave the formula column empty<BR />// no need to discuss this, because this obviously missing the 'eval(eval expr(expr()))' wrapping (see screenshot below)
dt << New Column( "QcParameter [% rel.]_1",
numeric,
formula(
curBatch = :BatchId;
curCondition = :StorageCondition;
theRows = dt << get rows where(
:BatchId == curBatch & :StorageCondition == curCondition & :Time == 0
);
d0Row = theRows[1];
d0Time = :QcParameter[d0Row];
(100 * :QcParameter / d0Time);
)
);
// adding formula column via approach nr. 2<BR />// this will fill the formula column as desired when copying and running the table script with the added formula columns<BR />// but it will also throw an error message when new rows are added to the table then (see screenshot below)
Eval(
Eval Expr(
dt << New Column( "QcParameter [% rel.]_2",
numeric,
formula(
curBatch = :BatchId;
curCondition = :StorageCondition;
theRows = Expr( dt ) << get rows where(
:BatchId == curBatch & :StorageCondition == curCondition & :Time == 0
);
d0Row = theRows[1]; // removed from approach nr. 3
d0Time = :QcParameter[d0Row];
(100 * :QcParameter / d0Time);
)
)
)
);
// adding formula column via approach nr. 3
// this will fill the formula column as desired when copying and running the table script with the added formula columns<BR />// and it will NOT throw an error message when new rows are added to the table then (see screenshot below)
Eval(
Eval Expr(
dt << New Column( "QcParameter [% rel.]_3",
numeric,
formula(
curBatch = :BatchId;
curCondition = :StorageCondition;
theRows = Expr( dt ) << get rows where(
:BatchId == curBatch & :StorageCondition == curCondition & :Time == 0
);
d0Time = :QcParameter[theRows];
(100 * :QcParameter) / d0Time;
)
)
)
);
追加の数式列を使用してテーブル スクリプトを再実行したときの、数式列「QcParameter [%r rel.]_1]」のエラー メッセージのスクリーンショット:

追加の数式列を使用してテーブル スクリプトを再実行したときの、数式列「QcParameter [%r rel.]_2]」のエラー メッセージのスクリーンショット:

追加の数式列を使用してテーブル スクリプトを再実行したときの、数式列「QcParameter [%r rel.]_3]」のエラー メッセージのスクリーンショット:

私がこの長い質問をしている理由は、次のように考えているからです。変数「d0Row」がアプローチ nr で使用されるのには、何らかの理由があるはずです。 2、いいえ?アプローチ番号については、 3 この変数を削除しただけです (以下のスクリーンショットを参照)。その結果、数式は「はるかに適切に」動作します。つまり、新しい行がデータ テーブルにポイント アンド クリックによってアドホックに追加されるときに、エラー メッセージが表示されません。

したがって、私の質問は、「d0Row」変数を削除することで何か間違ったことをしているかどうかです。 実際には、より大きなデータテーブルを操作しているため、各行の正確性を個別にチェックすることはできません。
あなたの問題に従っているかどうか完全にはわかりませんが、私が見ているのは、式1をコピーするときにdtへの参照があり、dtへの参照が欠落しているということです。例 2 と 3 では、データ テーブル参照がデータ テーブル "ExampleTable" を指すことになり、図に示すように、データ テーブル名は "Example Table 2" になります。繰り返しになりますが、私があなたの問題を理解しているのであれば、「Current Daa Table()」を使用することで問題を解決できると思います。
curBatch = :BatchId;
curCondition = :StorageCondition;
theRows = Current Data Table() << get rows where(
:BatchId == curBatch & :StorageCondition == curCondition & :Time == 0
);
d0Row = theRows[1];
d0Time = :QcParameter[d0Row];
If( Row() == 11,
Show( therows, d0Time )
);
(100 * :QcParameter) / d0Time;
この質問とは正確には関係ありませんが、Col-function マジックを使用して数式を「簡素化」できます。 これらの提案は機能するはずですが、古い有効な公式を置き換える前に検証する必要があります。
dt << New Column("FormulaA", Numeric, Continuous, Formula(
100 * :QcParameter / Col Sum(If(:Time == 0, :QcParameter, .),:BatchID, :StorageCondition)
));
時刻 0 が常にグループの最初になるようにデータを並べ替えると、さらに理解しやすくなります (おそらく)
dt << New Column("FormulaB", Numeric, Continuous, Formula(
100 * :QcParameter / QcParameter[Col Min(Row(), :BatchID, :StorageCondition)]
));