SSAS MDX 计算量度 - [ITEMS] 的计数。[Item] 分组 [Items]。[Item Group]

SSAS MDX Calculated Measure - COUNT of [ITEMS].[Item] grouped [Items].[Item Group]

在连接到 SSAS 的 Excel 中,我正在尝试构建一个枢轴 table 并使用 "OLAP Tools" and/or "OLAP Pivot Table Exensions" 添加自定义度量计算。我正在尝试添加一个在我看来非常简单的计算,但我无法让它工作。我需要的计算器是:

GOAL: A record count of the [Items] dimension records grouped by any of the [Items] dimension fields.

特别是我试图按 [Items].[Items Groups][Items].[Item] 分组。 Item 是最低粒度的,因此计数应该 return 值为“1”。我创建了一些大概的计算(见下文)。但是计算似乎没有按预期工作。

我试过的:

Attempt #1 -- [Measures].[Items Count (With net amount values)]

DISTINCTCOUNT( {[Items].[Item].MEMBERS} )

The calc 'Items Count (With net amount values)' appears to be returning a decent count value, but it appears it only counts the Item if there are transnational records found (not sure why). Also, when at the lowest grain level the calc returns that value for the parent group, not the dimension level selected on the rows.

Attempt #2 -- [Measures].[Items Count (All)]

[Items].[Item].[Item].Count

This calc returns the TOTAL item count for the entire dimension regardless of the dimension level placed on the rows.

Attempt #3 -- [Measures].[Items Count]

COUNT ( { [Items].[Item].MEMBERS}, EXCLUDEEMPTY)

This calc freezes up Excel and I have to quit Excel. No idea why. I have seen this sytnax recommended on a few different sites.

截图:

请帮忙?这看起来很简单,但我对 MDX 不是很熟练。在 DAX 和 SSAS TABULAR 中,这将是非常简单的表达式。但我正在努力计算 SSAS MD 中使用 MDX 的行数。

"Outside Purchased Beef"组有18个商品有交易,但一共41个商品。我不知道如何计算“41”值。

SSAS Excel-CalcMeasure-CountRows.png

查看 AdventureWorks 上的以下示例。

with member [Measures].[CountTest]
as 
count(existing  [Product].[Subcategory].members - [Product].[Subcategory].[All])
select 
{
[Measures].[Internet Sales Amount],[Measures].[CountTest]
}
on columns,
{
([Product].[Category].[Category]
,[Product].[Subcategory].[Subcategory] -- comment this line for the second result
)
}
on rows 
from [Adventure Works]

现在注释父视图的指定行。