조건이있는 이전 행 값의 롤링 합계내 데이터는 Lot # 및 Qty라는 두 개의 열로 시작합니다.
이전 행 값의 롤링 합계 (현재 행 + 이전 2 개 행)를 계산하는 스크립트를 만드는 데 도움이 필요합니다.
로직은 아래 표와 같습니다.

스크립팅Re : 조건이있는 이전 행 값의 롤링 합계한 가지 방법은 다음과 같은 공식을 사용하는 것입니다.

If( Row() == 1,
:Qty,
If( Row() == 2,
Lag( :Qty, 1 ) + :Qty,
:Qty + Lag( :Qty, 1 ) + Lag( :Qty, 2 )
)
)
첫 번째 행에는 합계 할 것이 없으므로 행 1 만 사용합니다.
두 번째 행에는 현재 값과 이전 값만 있으므로 해당 행 + lag (1)
두 번째 이후의 모든 행은 현재 행과 이전 두 행의 합계를 취합니다. : lag (1) 및 lag (2)
Re : 조건이있는 이전 행 값의 롤링 합계수식 사용 아이디어를 증명해 주셔서 감사합니다.
내 데이터 세트는 일부 로트 데이터가 계산되지 않기 때문에 공식을 사용하여 직접 합산을 수행 할 수 없습니다.
예,
Lot # 3 및 Lot # 3.2, 최종 로트 수량이므로 Lot # 3.2 수량 만 롤링 합계에 포함됩니다.
Lot # 3에 추가 수량이 추가되었습니다. Lot # 3.2가됩니다.
Lot # 7, 7,2, 7,3 및 Lot # 10, 10.3도 동일합니다.
Lot # 7.3 수량 및 10.3은 최종 로트 수량이므로 롤링 합계로 계산됩니다.
커뮤니티의지도가 필요합니다.

Re : 조건이있는 이전 행 값의 롤링 합계맞아, 이제 알 겠어.
각 로트에 대한 최대 값을 찾은 다음 현재 및 마지막 두 개의 최대 로트 값의 롤링 합계를 가져와야합니다.
나는 숨어있는 해결책이 있다고 느낍니다. 그것에 대해 조금 더 생각해야 할 수도 있습니다.
Re : 조건이있는 이전 행 값의 롤링 합계나는 이것을 얻는 방법을 알아낼 것이다.
누군가가 이것에 대한 해결책을 가지고 있다면, 함께 공유하십시오.
감사.
Re : 조건이있는 이전 행 값의 롤링 합계이게 옳은 거니. (사진에서 가장 오른쪽 열)?

Re : 조건이있는 이전 행 값의 롤링 합계그래 맞아.
하지만이 결과를 얻기 위해 일부 행을 제외하지 않고 원래 데이터 테이블을 유지하고 싶습니다.
할 수 있습니까?
Re : 조건이있는 이전 행 값의 롤링 합계이 스크립트를 데이터 테이블에 추가하고 회전 해보세요.
dt1=current data table();
//I want to get the max quantity by lot, so I'm adding a new column to change all the lots back to their non-decimal value.
dt1<< New Column("Lot Actual", formula(If( :Qty == Col Maximum( :Qty, Char( Round( Num( :Lot# ), 0 ) ) ),
:Lot#,
.
)));<BR />//this next formula column excludes rows that aren't the max Qty by lot
dt1<< New Column( "Lot Values in One Formula",
Formula(
If( :Lot Actual == "",
Row State( row() ) = Excluded State( 1 );
Excluded( Row State( row() ) );
1;
)
)
);
dt1<<RUN formulas=""></RUN>//once all the formulas for tagging the data are added, we can use Tabulate to get a subset of just the important rows.<BR />//There are lots of other ways to do this, this just happened to be the method of the day
obj1=dt1 << Tabulate(
Add Table(
Column Table( Analysis Columns( :Qty ) ),
Row Table( Grouping Columns( :Lot# ) )
)
);
dt2=obj1 << Make Into Data Table;
column(dt2,2)<<SET name=""></SET><BR />//Finally here is the rolling sum of the last three lots<BR />//there is moving average function we could have used, it would have looked simpler but more abstract
dt2<<NEW column=""></NEW>//<BR />//This part joins the values from the separate table back to the original table<BR />
dt1 << Update(
With( dt2 ),
Match Columns( :Lot# = :Lot# )
);
close(dt2, nosave);
obj1<<CLOSE window=""></CLOSE>//I feel like this step is cheating a little. This step just repeats the missing values down to the next non-missing<BR />//row. Its some code I got from Brady Brady a ways back. Different iterations of come in handy from time to time.
<BR />dtnr=current data table();
dtcollist=dtnr<<GET column="" names=""></GET>