Power BI 切片器过滤不起作用

kam*_*et_ 2 dax powerbi

这是我过去在这里开始的线程的延续

\n

一段时间后,我带着类似的问题回来,但这次我想充分了解这个问题,以最终解决它。

\n

假设我使用以下 Power BI 数据模型:

\n

在此输入图像描述

\n

根据模型,我构建了以下报告:

\n

在此输入图像描述

\n

正如您所看到的,在视觉效果上,我组合了 ProductCategory 和 Product 表中的属性。我还添加了一个度量,此处名为 [Some Measure],其定义如下:

\n
IF (\n    ItemStockHistory[# ItemStockCurrent] <= 0;\n    "No Stock";\n        DIVIDE (\n            ItemStockHistory[# ItemStockCurrent];\n            [\xce\xa3 SalesUnitQuantity_Last30Days]\n    )\n)\n
Run Code Online (Sandbox Code Playgroud)\n

这种度量构建的目标是向分析师显示属于特定类别的所有产品的明确价值,以防度量评估为空白。

\n

不幸的是,我发现覆盖度量中的“自然”空白可能会对表格视觉中显示的数据产生副作用:使用切片器进行过滤无法正常工作- 当我选择“Office”等特定产品类别时,我得到笛卡尔此类别的产品和所有 SKU(以及过滤类别之外的产品)

\n

对我来说,这是表格建模的相当令人惊讶的行为。为什么用显式值覆盖测量 BLANK 结果会影响过滤?

\n

大多数基于ProductSku级别的操作报告都共享类似的视觉设置,我真的希望支持格式化空白度量以及一些技术值,这些技术值仍然允许已建立的关系正常工作,而不会产生奇怪的效果,就像笛卡尔积或来自其他视觉效果的内切过滤器,比如切片器

\n

或者也许我不理解表格建模主要范式,并且想要了解该技术默认禁止的内容?

\n

编辑1

\n

缺失的ItemStockHistory表已添加到数据模型图中

\n

Ale*_*son 5

Replacing blanks with specific values can definitely lead to this sort of thing. A result can be blank because there are no corresponding data rows in your fact table or it can be blank because that combination isn't even possible in the dimension tables and you can't tell just from looking at a blank which of these which, so replacing a blank will apply to both or neither of these cases.

We'd like to ignore the impossible combinations. As @sergiom correctly points out, they occur as a result of auto-exist not kicking in because category and SKU don't exist in the same table. Because they are in different tables, the internal logic uses the more brute-force approach of cross-joining and filtering down. However, you've interfered with the filtering down part by replacing blanks with something else.

The way to get around this if you can't create a cleaner model is to check for an empty cross-join before evaluating the measure.

For example, instead of

IF ( ISBLANK ( [Measure] ); "No Stock"; [Measure] )
Run Code Online (Sandbox Code Playgroud)

You might write something with an extra check:

IF (
    ISEMPTY ( Product ),
    BLANK (),
    IF ( ISBLANK ( [Measure] ); "No Stock"; [Measure] )
)
Run Code Online (Sandbox Code Playgroud)

This way, you only evaluate the measure for cases that actually make sense.