【问题标题】:Why does my filter not work with calculated measures in Power BI, Power Pivot Excel?为什么我的筛选器不适用于 Power BI、Power Pivot Excel 中的计算度量?
【发布时间】:2016-12-27 15:51:44
【问题描述】:

我正在使用 AdventureWorksDW2014。我创建了 2 个度量,但是当我应用过滤器时,它们的行为并没有达到预期的效果。

我有 2 个表 FactInternetSales 和 DimCustomer。它们通过 CustomerKey 链接。 我有 2 个计算量度。一项衡量标准(所有性别)总结了运费。

All Gender Freight = CALCULATE( sum(InternetSale[FactInternetSales.Freight]))

另一种衡量方式总结了只有男性的运费

Male Measure Freight =
CALCULATE (
    SUM ( InternetSale[FactInternetSales.Freight] ),
    Customer[DimCustomer.Gender] = "M"
)

现在,如果我使用 Power BI 或 Power Pivot Excel 查看所有性别的第一个度量。我看到了这个。这是我所期望的。

Gender  All Gender

  F      370341.79

  M    363627.8142

对于第二个措施,我无法解释的是,我预计女性的总运费为零,因为我没有将其包含在我的措施中。

Gender  All Gender

  F    363627.8142 --Should be 0

  M    363627.8142

【问题讨论】:

    标签: ssas powerpivot powerbi dax


    【解决方案1】:

    你缺少FILTER函数:

    Male Measure Freight =
    CALCULATE (
        SUM ( InternetSale[FactInternetSales.Freight] ),
        FILTER(Customer,Customer[DimCustomer.Gender] = "M")
    )
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-23
      • 1970-01-01
      相关资源
      最近更新 更多