您好,我有幾列數據,我想添加另一個列,它將得到如下公式:
ABC
2 5
3 4
5 5
4 7
C 列將得到 if else 公式,例如: If(A&B==4 then C ==Good) else if(A&B==3 then C ==bad) else if(A&B==1 then C ==Good)
我怎樣才能把這個寫成公式呢?
此代碼將執行您所描述的操作:
New Table( "Untitled", Add Rows( 6 ),
New Column( "A", Numeric, "Continuous", Format( "Best", 12 ),
Set Values( [2, 3, 5, 4, 4, 1] ) ),
New Column( "B", Numeric, "Continuous", Format( "Best", 12 ),
Set Values( [5, 4, 5, 7, 4, 1] ) ),
New Column( "C", Character, "Nominal", Formula(
If( :A == 4 & :B == 4, "Good",
:A == 3 & :B == 3, "Bad",
:A == 1 & :B == 1, "Good"
)
)
)
);
克雷格的鏈接非常好,特別是因為它討論了空值會發生什麼。