【问题标题】:Counting records in another table that match criteria in PowerPivot计算另一个表中与 PowerPivot 中的条件匹配的记录
【发布时间】:2014-10-02 23:33:47
【问题描述】:

我有 2 张桌子:

  1. RefundData:包含退款详情(相关栏目名称:RefundAmount
  2. Buckets:3 列:BucketLowBucketHighCountOfRecords

退款金额从 0.01 美元到 25,000.00 美元不等。

我正在尝试计算RefundData 表中属于Buckets 表中每个存储桶级别的退款金额。

一些示例数据:

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 找不到或不能在此表达式中使用。

我错过了什么?

我觉得我真的很亲密,但缺少一些简单的东西。

【问题讨论】:

    标签: excel-2010 powerpivot


    【解决方案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])
              )
    

    【讨论】:

      猜你喜欢
      • 2019-06-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-12
      • 2021-09-22
      • 1970-01-01
      相关资源
      最近更新 更多