計數公式希望透過 col 變數建立 3 列,以便可以隨著變化而下降、向上計數以及從中點向上/向下計數。
自動化和腳本編寫基礎資料分析與建模內容組織資料混合與清理回覆:計算公式您正在尋找這樣的東西嗎?
“向下”
Col Cumulative Sum(Row() == Col Min(Row(), :Lot))
“向上”
Col Sum(Row() == Col Min(Row(), :Lot)) - Col Cumulative Sum(Row() == Col Min(Row(), :Lot)) + 1
中間
Col Cumulative Sum(Row() == Col Min(Row(), :Lot)) - Col Sum(Row() == Col Min(Row(), :Lot)) + 1
回覆:計算公式如果批次始終是連續的,則 Jarmo 的回應就是正確答案。但是,如果分組列不連續,例如
A
A
A
B
B
A
A
C
C
C
那麼提供的公式將不正確。以下是處理不連續分組的替代公式
向下
As Constant( count = 0 );
If( :Lot != Lag( :Lot ),
count
++);
count;
向上
As Constant(
count = 0;
For Each Row( If( :Lot != Lag( :Lot ), count++ ) );
count = count + 1;
);
If( :Lot != Lag( :Lot ),
count
--);
count;
中間
As Constant(
count = 0;
For Each Row( If( :Lot != Lag( :Lot ), count++ ) );
count = count + 1;
count = -1 * Ceiling( count / 2 );
);
If( :Lot != Lag( :Lot ),
count
++);
count;
回覆:計算公式嗨@DELANDJ1985 ,
我對如何做到這一點的看法與@jthi和@txnelson略有不同。請參閱隨附的 jmp 文件,其中我為每個計數方案定義了單獨的列公式。我對每個問題的處理都略有不同,因此您可以接受這個概念,並可能根據您手頭上的特定問題對其進行修改。您的查詢甚至可能有不只一個可能的答案!
您不必建立列公式,但可以將其編寫為腳本並將其作為腳本運行,這樣該列就不會被鎖定。但是,該細節取決於您特定場景的需求。
希望有幫助!
DS