回复:如何使用列表中的列名創建列公式您遇到了未正確處理具有多個列名的行的問題。這是我嘗試解決您的問題。

Names Default To Here( 1 );
Clear Globals();
dt = Data Table( "Untitled 910" );
dt2 = Data Table( "Soft Bin Summary" );
current data table(dt);
// Build execution string
sumString = "";
for each row(
if(:Yield SummaryBins != "",
i=1;
while(word(i,:Yield SummaryBins,"[] ") != "",
sumString = sumString || ", :\!"" || word(i,:Yield SummaryBins,"[] ") || "\!"n";
i++;
)
)
);
// Remove first comma
sumString = substr(sumString, 1);
// Execute new column string
eval(parse("dt2<<NEW column=""></NEW>回复:如何使用列表中的列名創建列公式謝謝吉姆。
您的代碼有效。 我想為每個組創建單獨的列。
例如:在下面的例子中,有兩組 Opens 和 Shorts,其中包含各自的列名。
我想要兩個不同的列,其中的公式對各自的值求和
摘要表中的第 1 列(列 (39, 41, 43) 的總和)和列 2(列 (38, 40, 42) 的總和)

回复:如何使用列表中的列名創建列公式這只是擴展我提供的代碼的問題。
Names Default To Here( 1 );
Clear Globals();
dt = Data Table( "Untitled 910" );
dt2 = Data Table( "Soft Bin Summary" );
Current Data Table( dt );
// Build execution string
openString = shortsString = "";
For Each Row(
If( :Yield SummaryBins != "",
If( :Yield SummaryLabel == "Opens",
i = 1;
While( Word( i, :Yield SummaryBins, "[] " ) != "",
openString = openString || ", :\!"" || Word( i, :Yield SummaryBins, "[] " ) || "\!"n";
i++;
);
);
If( :Yield SummaryLabel == "Shorts",
i = 1;
While( Word( i, :Yield SummaryBins, "[] " ) != "",
shortsString = shortsString || ", :\!"" || Word( i, :Yield SummaryBins, "[] " ) || "\!"n";
i++;
);
);
)
);
// Remove first comma
openString = Substr( openString, 1 );
shortsString = Substr( shortsString, 1 );
// Execute new column strings
Eval( Parse( "dt2<<NEW column=""></NEW>
請花時間研究提供的代碼,如果您不了解代碼的工作原理,請回答其他問題。
回复:如何使用列表中的列名創建列公式當然可以……有什麼規定?回复:如何使用列表中的列名創建列公式你好@txnelson ,你能建議嗎?
回复:如何使用列表中的列名創建列公式我讀到你的描述是你的規則是為條件表中的每一行創建一個新列,該列在 Yield SummaryLabel 列中有一個值。
因此,我建議您通讀條件表中的每一行,當您在 Yield SummaryLabel 列中找到具有值的行時,您可以創建新列。
在一種情況下,您遇到了問題。第 14 行指定了 SYL_Yield,Yield SummaryBins 的值為 1。沒有名為“1”的列。

回复:如何使用列表中的列名創建列公式可以排除第 14 行。 你能分享代碼嗎? 我只是想參考並獲得一個想法
回复:如何使用列表中的列名創建列公式Names Default To Here( 1 );
dt = Data Table( "Condition table" );
dt2 = Data Table( "Soft Bin Summary" );
Current Data Table( dt );
// Rule: Create a new Summary Column for each row in the Condition Table
// that has a value in the Yield SummaryLabel column
For( i = 1, i <= N Rows( dt ), i++,
If( dt:Yield SummaryLabel[i] != "",
theString = "";
k = 1;
While( Word( k, dt:Yield SummaryBins[i], "[] " ) != "",
theString = theString || ", :\!"" || Word(
k,
dt:Yield SummaryBins[i],
"[] "
) || "\!"n";
k++;
);
theString = Substr( theString, 1 );
Eval(
Parse(
"dt2<<NEW column=""></NEW>
社區成員因幫助其他成員而獲得的唯一補償是來自他們幫助的成員變得更加自給自足的滿足感。剪切和粘貼別人的工作代碼並不是實現自給自足的好方法。
回复:如何使用列表中的列名創建列公式@txnelson謝謝你。 非常感激。
可以動態完成嗎? 我遇到過超過 2 個組的情況。 編寫單獨的字符串執行函數會很乏味。
我在下面附上了參考表
回复:如何使用列表中的列名創建列公式@txnelson規則與前面的示例類似。
使用對各個 bin 求和的公式創建每個單獨的 Column 組。
我想在 Soft Bin Summary 表中創建一個列,並在公式中添加所有列名 bin。
例如:使用公式 (Sum( Column ("52", "42","49") )) 創建 IDD Currents 組列,
使用公式創建開放組列(總和(列(“39”,“41”,“43”)))
對產量摘要標籤列中的其餘標籤組也是如此
如何使用列表中的列名創建列公式你好,
我想在第二個 JMP 表中創建一個新列使用一個簡單地對列表中包含的列求和的公式(在我已將列名分配給的代碼中箱子。
例如:該列表包含列名稱“39”、“41”、“43”。 我想在 Soft Bin Summary 表中創建一個新列,並在公式中添加所有這些
從列列表 {""} 到對列的引用,我無法弄清楚我在做什麼錯。
任何幫助深表感謝。
這是我試過的代碼
Names Default To Here( 1 );
Clear Globals();
dt = Data Table( "Untitled 910" );
dt2 = Data Table( "Soft Bin Summary" );
Try( For Each Row( :Yield SummaryBins = Word( 1, :Yield SummaryBins, "[]" ) ) );
grouplist = dt:Yield SummaryBins << get values;
For( i = N Items( grouplist ), i >= 1, i--,
If( grouplist[i] == "",
Remove From( grouplist, i, 1 ),
));
binss = {}; /// list contaiting bin value
For( i = 1, i <= N Items( grouplist ), i++,
If( Contains( grouplist[i], " " ),
Insert Into( binss, grouplist[i] )
)
);
adad = Words( binss[1], " " );
F = Eval Expr( Sum( Expr( adad ) ) );
/// Something doesn't seem to right in the below loop
For( i = 1, i <= N Items( binss ), i++,
dt2 << New Column( binss[i], "Numeric", "Continuous", Format( "Percent", 12, 2 ), Formula( Name Expr( F ) ) ););
謝謝,
傑克
高級統計建模數據探索和可視化大規模定制質量與工藝工程