다른 열의 동일한 그룹화 값에 대한 if 문에서 행 선택을 확장하는 방법은 무엇입니까? 첨부 파일의 경우 7행이 다음과 같이 선택된 경우:
dt << select where (:D1 > 1);
선택은 이 경우 모두 "B"인 열 G1의 모든 그룹화 값에 대해 확장되어야 합니다.
데이터가 SQL에 의해 업데이트되기 때문에 수식 열을 요청하고 있습니다. 인덱스 번호가 있는 기존 수식 열은 새 데이터와 관련하여 자동으로 업데이트됩니다.
공식 버전으로 무엇을 하고 싶은지 잘 모르겠습니다.즉, 어떤 값이 새 열에 포함될 것으로 예상하고 있지만 아래는 귀하가 원하는 작업에 대한 제 추측입니다.
참고로 수식 버전은 모든 행에 대해 한 번 실행해야 하므로 스크립팅 버전만큼 효율적이지 않습니다.
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));다시 한 번 코드에 감사드립니다. 의도한 대로 작동합니다. 수식으로 사용하려면 코드에 무엇을 변경하거나 추가해야 합니까?
빠른 답변에 감사드립니다. 내 질문이 맞았어. 당신의 스크립트는 내가 찾던 것을 정확히 전달합니다.
귀하의 질문에 대한 몇 가지 다른 해석이 있지만, 제가 해결하고 있는 것이 올바른 해석이기를 바랍니다.내 대본을보고 그것이 당신이 생각한 것인지 말해주십시오.
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));