2014-03-03 75 views
0

我有一個跟蹤玩家資料表:訪問計算字段與IF

Player  Pts Reb Ast Blk Stl Tov 
Jeff Teague 21  11  15  1  2  4 

我想補充一點,計算出該玩家取得的幻想點計算的字段。球員得到:

1 fantasy point per Pts 
1.25 fantasy points per Reb 
1.5 fantasy points per Ast 
2 fantasy points per Ast 
2 fantasy points per Stl 
-.5 fantasy points per Tov 
1.5 fantasy points IF any two of Pts, Reb, Ast, Blk, or Stl are 10 or more 
3 fantasy points IF any three of Pts, Reb, Ast, Blk, or Stl are 10 or more 

因此,在這個例子中,他會得到(21)+(11×1.25)+(15×1.5)+(2)+(2×2) - (5 * 4) +(1.5)+(3)= 61.75個幻想點。額外的1.5和3是因爲Pts,Ast和Reb都是10或更大。

到目前爲止計算字段我有:

([PTS])+([TRB]*1.25)+([AST]*1.5)+([STL]*2)+([BLK]*2)-([TOV]*.5) 

但我無法弄清楚如何將最後兩個因素的IF語句。

+0

每個Ast1.5個幻想點每個Ast2個幻想點。你說的1.5和2分爲Ast –

回答

2

它是一種討厭的計算,但這裏是你怎麼做:

[PTS] 
+ [TRB] * 1.25 
+ [AST] * 1.5 
+ [STL] * 2 
+ [BLK] * 2 
- [TOV] * 0.5 
+ iif(
    iif([PTS] >= 10, 1, 0) 
    + iif([Reb] >= 10, 1, 0) 
    + iif([AST] >= 10, 1, 0) 
    + iif([Blk] >= 10, 1, 0) 
    + iif([Stl] >= 10, 1, 0) = 2 
    , 1.5 
    , 0 
) 
+ iif(
    iif([PTS] >= 10, 1, 0) 
    + iif([Reb] >= 10, 1, 0) 
    + iif([AST] >= 10, 1, 0) 
    + iif([Blk] >= 10, 1, 0) 
    + iif([Stl] >= 10, 1, 0) = 3 
    , 3 
    , 0 
) 

也就是說,使用iif()每個比較01轉換,然後一起添加這些,並比較了閾值數量。

+0

除了Reb應該大於或等於這個事實之外,這個伎倆。謝謝! – fullOfQuestions