更新:当我试图提供一个简单的例子来重现这个问题时,我在我的数据库中发现了引入这个问题的调平器。因此,我对这个问题进行了更新,以反映这一新发现。您将在下面找到用于设置重现此问题的数据库的脚本。
我在服务器版本 2008 和 2012 中遇到了 Analysis Services 的奇怪行为。
在我的 AS 数据库中,我定义了一个带有基本度量的多维数据集,如下所示:
AggregateFunction: Min;
Name: Existing Data
Run Code Online (Sandbox Code Playgroud)
如您所见,聚合函数是Min。
包含相应existing_data列的事实表仅包含0或1值。目标是在数据选择包含链接到零值的类别时立即返回零。该矩阵表示存储在另一个事实表中的真实事实中已经/尚未为其收集数据的区域,因此我们可以区分结果是否为零,因为在所选区域中没有任何案例,或者因为在所选区域中尚未收集到任何病例的地区。
当我现在运行以下查询时,我为每个选定的类别获得 1:
WITH
SET [adhoc] AS 'UNION(
DESCENDANTS([Gebiete].[Hierarchie].[Bezirk].[010],[Gebiete].[Hierarchie].[Landkreis]),
DESCENDANTS([Gebiete].[Hierarchie].[Bundesland].[10],[Gebiete].[Hierarchie].[Landkreis])
)'
SELECT [adhoc] ON 0
FROM [Testdb]
WHERE ([Measures].[Existing Data])
Run Code Online (Sandbox Code Playgroud)
结果
01001 01002 10041 10042
1 1 1 1
Run Code Online (Sandbox Code Playgroud)
当我现在将此查询更改为以下内容时,我希望一个包含 1 的单元格作为结果,因为该Min()函数聚合的所有值都是 1(与之前的结果相比):
WITH
SET [adhoc] AS 'UNION(
DESCENDANTS([Gebiete].[Hierarchie].[Bezirk].[010],[Gebiete].[Hierarchie].[Landkreis]),
DESCENDANTS([Gebiete].[Hierarchie].[Bundesland].[10],[Gebiete].[Hierarchie].[Landkreis])
)'
MEMBER [Gebiete].[Hierarchie].[adhoc] AS 'Aggregate([adhoc])'
SELECT {[Gebiete].[Hierarchie].[adhoc]} ON 0
FROM [Testdb] …Run Code Online (Sandbox Code Playgroud)