
やあみんな!
この投稿の下にサンプルファイルを添付しました。
現在、差の割合を計算しようとしていますが、
これは (新しい値 - 元の値)/元の値で与えられます
この場合、時刻 0 が参照 (元の値) として取得されます。
例えば:
時間: 0、パート: 1 値 1: 690.2
時間: 50、パート: 1、値 1: 690.52
(690.52-690.2)/(690.2) = 0.046%
時間: 100、部分: 1、値 1: 689.25
(689.25-690.2)/(690.2)= -0.13%
私が得ると思われる結果は、Time、id、Part が変更されていない新しいテーブルを持つことです。
値 1 と値 2 の新しい値がパーセンテージ形式で表示されます。
別の時間の値を別のテーブルに移動することを考えましたが、
次に、Time 0 に対して計算し、新しいテーブルに追加しますが、手がかりがありません
スクリプトでの書き方。
「Percentage Different Progress」ファイルにいくつかのスクリプトを書きましたが、行き詰まっています。
誰かがこれで私を助けてくれれば、本当に感謝しています。
よろしくお願いします。

値 2 の結果は、値 1 の結果を簡単に置き換えることができます。
いいえ、すべての列に対して JSL をハードコーディングする必要はありません。以前のコードを拡張して、データ テーブルにある列と同じ数の列に対してこれを実行する方法を説明しました。また、Time=0 行の元の Value1 データを変更したくないという前提もありましたが、そうでない場合は、その決定を行っている If() ステートメントを削除してください。
Names Default To Here( 1 );
dt = Current Data Table();
// Create a subset with only the data where Time = 0
dt2 = dt << subset( Rows( dt << get rows where( :Time == 0 ) ), selected columns( 0 ) );
// Delete the Time column. In the join step below, it
// will write on top of the original Time column if
// it remains in the subsetted data table
dt2 << delete columns( "Time" );
// Create a list of the column names so all of them can be
// changed to a new name for the Join below. Eliminate
// the columns "id" and "Part" from the name change since
// they will be used in the column matching in the Join.
divisorColNames = dt2 << get column names( string );
For( i = N Items( divisorColNames ), i >= 1, i--,
If( divisorColNames[i] == "id" | divisorColNames[i] == "Part",
divisorColNames = Remove( divisorColNames, i, 1 )
)
);
// Rename all of the divisor columns by "adding divisor_"
// in front of each name
For( i = 1, i <= N Items( divisorColNames ), i++,
Column( dt2, divisorColNames[i] ) << set name(
"divisor_" || Char( Column( dt2, divisorColNames[i] ) << get name )
)
);
// Join the data tables. All of the matching id and part
// values will be joined to all rows with the same values
dtJoin = dt << Join(
With( dt2 ),
Merge Same Name Columns,
Match Flag( 0 ),
By Matching Columns( :id = :id, :Part = :Part ),
Drop multiples( 0, 0 ),
Include Nonmatches( 1, 0 ),
Preserve main table order( 1 )
);
// The dt2 data table is no longer needed so close it
Close( dt2, nosave );
// Loop through all of the columns and create the new values
// unless the Time value is 0
For( theCol = 1, theCol <= N Items( divisorColNames ), theCol++,
For( theRow = 1, theRow <= N Rows( dtJoin ), theRow++,
If( dtJoin:Time[theRow] != 0,
Column( dtJoin, divisorColNames[theCol] )[theRow] = (
Column( dtJoin, divisorColNames[theCol] )[theRow]
-Column( dtJoin, "divisor_" || divisorColNames[theCol] )[theRow]) /
Column( dtJoin, "divisor_" || divisorColNames[theCol] )[theRow]
)
)
);
// Delete all of the no longer needed divisor columns
For( i = 1, i <= N Items( divisorColNames ), i++,
dtJoin << delete columns( "divisor_" || divisorColNames[i] )
);
こんにちはジム!
助けてくれてありがとう。
何か方法はないか悩んでいます
1) 列値 1 の初期セルの値 2 (結果) を置き換えます。
2)実際にこの操作を行う必要がある列(30など)がさらにある場合(パーセント差)、
すべての新しい列をハードコーディングする必要がありますか、または列の作成を乗算または for ループする方法はありますか。
あなたが何を望んでいるのか理解できれば、これがあなたが望むことを行う最も簡単な方法だと思います。
dt = Current Data Table();
dt2 = dt << subset(
Rows( dt << get rows where( Time == 0 ) ),
columns( {"id", "Part", "Value1"} )
);
dt2:Value1 << set name( "divisor" );
dtJoin = dt << Join(
With( dt2 ),
Merge Same Name Columns,
Match Flag( 0 ),
By Matching Columns( :id = :id, :Part = :Part ),
Drop multiples( 0, 0 ),
Include Nonmatches( 1, 0 ),
Preserve main table order( 1 )
);
Close( dt2, nosave );
dtJoin << New Column( "Value2",
Numeric,
"Continuous",
Format( "Percent", 10, 4 ),
Formula( (:Value1 - :divisor) / :divisor )
);
dtJoin:Value2 << delete property( "formula" );
dtJoin << delete columns( "divisor" );