如何計算特定行中的非空白行數?我在這裡顯示了表格,並希望創建一個包含“N”的新列,“N”是具有數字的列數,但僅適用於標記為“DecodeCount_BW**”的列。例如,對於第一行,它應該返回“5”,對於第二行,它應該返回“2”,等等
在Excel 中,我使用“counta”執行此操作,但嘗試學習JMP 以改進統計分析,但我陷入了這樣的簡單事情,可能是由於我的Excel 格式的大腦......抱歉,如果這是超級基礎,但我在公式列表中找不到執行此操作的公式。
謝謝
JMP17用戶
內容組織資料混合與清理回覆:如何計算特定行中的非空白行數?公式通常不能輕易地朝這個方向工作(按行而不是按列計算某些內容)。根據您正在執行的操作,首先堆疊資料可能會有所幫助。
您可以使用公式(可能有點挑剔),但通常我會使用腳本。下面是一個例子

Names Default To Here(1);
dt = New Table("Untitled 3",
Add Rows(3),
Compress File When Saved(1),
New Column("Column 1", Numeric, "Continuous", Format("Best", 12), Set Values([., ., .])),
New Column("Column 2", Numeric, "Continuous", Format("Best", 12), Set Values([., ., .])),
New Column("AB1", Numeric, "Continuous", Format("Best", 12), Set Values([2, ., .])),
New Column("AB2", Numeric, "Continuous", Format("Best", 12), Set Values([., 2, 1])),
New Column("AB3", Numeric, "Continuous", Format("Best", 12), Set Values([., 5, .]))
);
dt << New Column("N", Numeric, Continuous);
cols_of_interest = Filter Each({colname}, dt << Get Column Names("String"),
Starts With(colname, "AB");
);
For Each Row(Current Data Table(),
:N = Sum(!Is Missing(dt[Row(), cols_of_interest]));
);
如果你真的想使用公式,也許可以使用這樣的東西
As Constant(cols_of_interest = Filter Each({colname}, Current Data Table() << Get Column Names("String"),
Starts With(colname, "AB");
));
Sum(!Is Missing(dt[Row(), cols_of_interest]));
您必須計算自己的比較,以過濾到感興趣的列(開始於也應該適用於您的資料)
回覆:如何計算特定行中的非空白行數?表格/摘要可以為您提供協助。要使其計算多列,您必須先堆疊資料:
dt = New Table( "test",
Add Rows( 6 ),
New Column( "W8",Set Values( [2, 5, ., 5, ., 6] )),
New Column( "W9",Set Values( [2, ., 3, 3, 1, 2] )),
New Column( "W1",Set Values( [2, ., ., ., ., .] )),
New Column( "W2",Set Values( [3, ., ., ., ., .] )),
New Column( "W3",Set Values( [3, ., ., ., ., .] )),
New Column( "W4",Set Values( [., ., 4, ., 2, .] )),
New Column( "W5",Set Values( [., 2, ., ., ., .] )),
New Column( "W6",Set Values( [., ., 5, ., 3, .] )));
dt << New Column( "row",Formula( Row() ));
dtstack =dt << Stack( columns( :W8, :W9, :W1, :W2, :W3, :W4, :W5, :W6 ),"Non-stacked columns"n( Keep( :row ) ));
dtstack << Summary( Group( :row ), N( :Data ) );
順便一提:
"Non-stacked columns"n
需要寫為"..."n 的命名參數。啊!
增強日誌知道這些細節有多好...