这是我在SO上发布的另一个question的延续。所以最新发生的是COUNT(NONEMPTY
似乎让我得到了计数但DISTINCTCOUNT
没有。我运行函数的集合(值)实际上是不同的。这是我正在使用的查询:
WITH MEMBER Measures.[x] AS
Count(
NONEMPTY(
[Request].[RequestID].children
, {([Measures].[Average of Late Tasks])}
)
)
MEMBER Measures.[y] AS
DISTINCTCOUNT((
[Request].[RequestID].children
, {([Measures].[Average of Late Tasks])}
) )
WITH MEMBER Measures.[z] AS
Count(DISTINCT
NONEMPTY(
[Request].[RequestID].children
, {([Measures].[Average of Late Tasks])}
))
)
SELECT
{Measures.[x], Measures.[y]} ON 0,
[Calendar].[CalendarMonthName].children ON 1
FROM [Model]
WHERE
([Calendar].[CalendarYear].&[2014],
[User].[UserID].&[033343])
输出
x y z
January 1 0 1
February 1 0 1
March 1 0 1
April 1 0 1
May 1 0 1
June 1 0 1
July 1 0 1
August 6 0 6
September 6 0 6
October 7 0 7
November 0 0 0
December 0 0 0
问题是,为什么COUNT(NONEMPTY(
有效,但DISTINCTCOUNT没有?当RequestID都是截然不同的时候也是如此!
例如,我检查了8月份的RequestID(Count = 6,见上面的结果)。
我运行了下面的MDX:
SELECT
[Measures].[Average of Late Tasks] ON 0,
non empty ([Calendar].[CalendarMonthName].&[August], [Request].[RequestID].children) ON 1
FROM [Model]
WHERE
([Calendar].[CalendarYear].&[2014],
[User].[UserID].&[033343])
输出
Average of Late Tasks
August 3157 0.00
August 3337 0.00
August 3769 0.00
August 4012 0.00
August 4191 0.00
August 1.22
这意味着它们都是不同的要求!然而,DISTINCTCOUNT
返回0.这里背景中发生了什么?!
答案 0 :(得分:0)
NonEmpty
是一个有一个或两个参数的函数,它们都应该是集合according to the documentation。另一方面,DistinctCount
是一个只有一个参数的函数,它应该是一个集according to the documentation。无论你在括号中构造什么
([Request].[RequestID].children
, {([Measures].[Average of Late Tasks])}
)
是,它不是一个格式良好的集合定义。您可能想要使用什么而不是
DISTINCTCOUNT((
[Request].[RequestID].children
, {([Measures].[Average of Late Tasks])}
) )
可能是
DISTINCTCOUNT(Filter(
[Request].[RequestID].children
, Not(IsEmpty([Measures].[Average of Late Tasks]))
) )
IsEmpty
检查MDX中的NULL值。您无法使用=
执行此操作,因为在数字上下文中,=
将NULL视为0。
无论如何,我认为这比其他两种解决方案要慢。