2014-10-02 62 views
0

標準,我已經有2個表:計數記錄匹配的PowerPivot

  1. RefundData:包含退款的詳細信息(有關列名:RefundAmount
  2. Buckets:3米欄:BucketLowBucketHighCountOfRecords

退款金額範圍從$ 0.01到$ 25,000.00。

我試圖計算Buckets表中每個桶級別內的RefundData表中的退款金額。

某些樣本數據:

RefundAmount 
0.29 
81.75 
1000.25 
1500.74 
2154.55 
125.52 

BucketLow BucketHigh CountOfRecords 
0   1000   3 
1000   2000   2 
2000   3000   1 

我已經試過:

CountOfRecords字段我已經嘗試添加下面的表達式來計算的RefundAmount的發生是> = BucketLow' AND < BucketHigh`

=calculate(count('RefundData'[RefundAmount]),'RefundData'[RefundAmount]>=[BucketLow],'RefundData'[RefundAmount]<[BucketHigh]) 

的PowerPivot是給我下面的錯誤:

BucketLow找不到或不能在此表達式中使用。

我錯過了什麼?

我覺得我真的很接近但缺少一些簡單的東西。

回答

1

我想通了。小的語法問題。 PowerPivot中的CALCULATE函數採用至少1參數

  1. 表達式(必需)
  2. [過濾器1](可選)
  3. [過濾器2](可選)
  4. 等...

我原本以爲我只能把我的過濾器要求放在CALCULATE這樣的功能中:

'RefundData'[RefundAmount]>=[BucketLow] 

但代替濾波器參數需要封裝到另一個功能:FILTER

所以不是這樣的:

=CALCULATE(
      COUNT('RefundData'[RefundAmount]), 
      'RefundData'[RefundAmount]>=[BucketLow], 
      'RefundData'[RefundAmount]<[BucketHigh] 
     ) 

的公式應該是這樣的:

=CALCULATE(
      COUNT('RefundData'[RefundAmount]), 
      FILTER('RefundData','RefundData'[RefundAmount]>=[BucketLow]), 
      FILTER('RefundData','RefundData'[RefundAmount]<[BucketHigh]) 
     )