他の列からの同じグループ化値の if ステートメントから行選択を拡張する方法は? 添付ファイルの行 7 が次のように選択されている場合:
dt << select where (:D1 > 1);
選択は、列 G1 のすべてのグループ化値に拡張する必要があります。この場合、すべて「B」です。
データはSQLによって更新されるため、数式列を求めています。 インデックス番号を持つ既存の数式列は、新しいデータに関して自動的に更新されています。
数式バージョンで何をしたいのかわかりません。つまり、新しい列に最終的にどのような値が含まれると予想されますが、以下は、何をしたいのかについての私の推測です。
参考までに、数式バージョンは、すべての行に対して 1 回実行する必要があるため、スクリプト バージョンほど効率的ではありません。
If( Row() == 1,
dt = Current Data Table();
d1Rows = dt << get rows where( :D1 > 1 );
g1Values = {};
If( N Rows( d1Rows ) > 0,
For( i = 1, i <= N Rows( d1Rows ), i++,
Insert Into( g1Values, dt:G1[d1Rows[i]] )
)
);
);
If( Contains( g1Values, :G1 ),
x = 1;
Row State( Row() ) = Selected State( 1 );
,
x = 0
);
x;
数式が適用されたデータ テーブル スクリプトを次に示します。
New Table( "IfSelRows",
Add Rows( 15 ),
Compress File When Saved( 1 ),
New Column( "G1",
Character( 1 ),
"Nominal",
Set Values(
{"A", "A", "A", "A", "A", "B", "B", "B", "B", "B", "C", "C", "C", "C",
"C"}
),
Set Display Width( 76 )
),
New Column( "D1",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 0, 0, 0, 0, 0] ),
Set Display Width( 58 )
),
New Column( "Column 3",
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula(
If( Row() == 1,
dt = Current Data Table();
d1Rows = dt << get rows where( :D1 > 1 );
g1Values = {};
If( N Rows( d1Rows ) > 0,
For( i = 1, i <= N Rows( d1Rows ), i++,
Insert Into( g1Values, dt:G1[d1Rows[i]] )
)
);
);
If( Contains( g1Values, :G1 ),
x = 1;
Row State( Row() ) = Selected State( 1 );
,
x = 0
);
x;
)
)
)コードに感謝します。 意図したとおりに機能します。 数式列として使用するには、コードに何を変更または追加する必要がありますか?
@txnelson書きました:
あなたの質問にはいくつかの異なる解釈がありますが、私が解決しているものは正しいものであることを願っています.私のスクリプトを見て、それがあなたが考えていたものかどうか教えてください
Names Default To Here( 1 );
dt = New Table( "IfSelRows",
Add Rows( 15 ),
Compress File When Saved( 1 ),
New Column( "G1",
Character( 1 ),
"Nominal",
Set Values( {"A", "A", "A", "A", "A", "B", "B", "B", "B", "B", "C", "C", "C", "C", "C"} ),
Set Display Width( 76 )
),
New Column( "D1",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 0, 0, 0, 0, 0] ),
Set Display Width( 58 )
)
);
// Get the rows where D1 > 1
d1Rows = dt << get rows where( :D1 > 1 );
// Create a list with the values of G1 for the rows that have been selected
g1Values = {};
If( N Rows( d1Rows ) > 0,
For( i = 1, i <= N Rows( d1Rows ), i++,
Insert Into( g1Values, dt:G1[d1Rows[i]] )
)
);
// Select the rows where any of the values in the g1List exist
dt << select where(contains(g1Values,:G1));コードに感謝します。 意図したとおりに機能します。 数式として使用するには、コードに何を変更または追加する必要がありますか?
Jim さん、素早い返信ありがとうございます。 あなたは私の質問を正しく理解しました。 あなたのスクリプトは、私が探していたものを正確に提供します。
あなたの質問にはいくつかの異なる解釈がありますが、私が解決しているものは正しいものであることを願っています.私のスクリプトを見て、それがあなたが考えていたものかどうか教えてください
Names Default To Here( 1 );
dt = New Table( "IfSelRows",
Add Rows( 15 ),
Compress File When Saved( 1 ),
New Column( "G1",
Character( 1 ),
"Nominal",
Set Values( {"A", "A", "A", "A", "A", "B", "B", "B", "B", "B", "C", "C", "C", "C", "C"} ),
Set Display Width( 76 )
),
New Column( "D1",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 0, 0, 0, 0, 0] ),
Set Display Width( 58 )
)
);
// Get the rows where D1 > 1
d1Rows = dt << get rows where( :D1 > 1 );
// Create a list with the values of G1 for the rows that have been selected
g1Values = {};
If( N Rows( d1Rows ) > 0,
For( i = 1, i <= N Rows( d1Rows ), i++,
Insert Into( g1Values, dt:G1[d1Rows[i]] )
)
);
// Select the rows where any of the values in the g1List exist
dt << select where(contains(g1Values,:G1));