MDX - 包括空和非空
MDX - include both empty and non empty
我有一个在 SSRS 报告中使用的 mdx 查询。我只想显示 > 50 的 return 小时,但我想显示所有年份,无论该年份是否有数据。我可以让 > 50 过滤器工作,但随后我失去了没有数据的年份。我曾尝试将年份放在 "Pages" 轴上,然后 return 一直都是,但是当我这样做时,我的行轴不再考虑过滤器。我也试过将年份维度放在 NONEMPTY 子句之外,但它同样不符合 > 50 小时过滤器。
这是我目前所获得的示例:
SELECT
[measures].[Hours] ON COLUMNS
,
[Date].[Year].[Year].ALLMEMBERS
*
{
Filter
(
NonEmpty
(
CrossJoin
(
[Client].[Client].[Client].ALLMEMBERS
,[Department].[Department].[Department].ALLMEMBERS
,[Title].[Title].[Title].ALLMEMBERS
,[Person].[Person].[Person].ALLMEMBERS
)
,[Measures].[Billable Hours]
)
,
[Measures].[Billable Hours] >= 50
)
} ON ROWS
FROM TestCube;
期望的结果是即使没有数据也仍然显示 2017 年的列,并且对于有数据的列只显示 > 50 小时。
如有任何帮助,我们将不胜感激。我确实找到了解决方法,方法是创建一个计算成员来检查小时 > 50,否则 return 为空。只是想知道是否有更好的方法来做到这一点。
谢谢,
希拉里
您可以尝试在筛选条件中添加OR ISEMPTY([Measures].[Billable Hours])
:
SELECT
[measures].[Hours] ON COLUMNS
,
[Date].[Year].[Year].ALLMEMBERS
*
{
Filter
(
NonEmpty
(
CrossJoin
(
[Client].[Client].[Client].ALLMEMBERS
,[Department].[Department].[Department].ALLMEMBERS
,[Title].[Title].[Title].ALLMEMBERS
,[Person].[Person].[Person].ALLMEMBERS
)
,[Measures].[Billable Hours]
)
,
[Measures].[Billable Hours] >= 50
OR ISEMPTY([Measures].[Billable Hours])
)
} ON ROWS
FROM TestCube;
您可以将算法移动到计算的度量中。它更快。过滤功能很慢。
with
Member [Measures].[Billable Hours 50More] as
IIF([Measures].[Billable Hours] >= 50, [Measures].[Hours], NULL)
select
[Measures].[Billable Hours 50More] on 0,
[Date].[Year].[Year].AllMembers * NonEmpty([Client].[Client].[Client].AllMembers * [Department].[Department].[Department].AllMembers * [Title].[Title].[Title].AllMembers * [Person].[Person].[Person].AllMembers, [Billable Hours 50More]) on 1
from TestCube
我有一个在 SSRS 报告中使用的 mdx 查询。我只想显示 > 50 的 return 小时,但我想显示所有年份,无论该年份是否有数据。我可以让 > 50 过滤器工作,但随后我失去了没有数据的年份。我曾尝试将年份放在 "Pages" 轴上,然后 return 一直都是,但是当我这样做时,我的行轴不再考虑过滤器。我也试过将年份维度放在 NONEMPTY 子句之外,但它同样不符合 > 50 小时过滤器。
这是我目前所获得的示例:
SELECT
[measures].[Hours] ON COLUMNS
,
[Date].[Year].[Year].ALLMEMBERS
*
{
Filter
(
NonEmpty
(
CrossJoin
(
[Client].[Client].[Client].ALLMEMBERS
,[Department].[Department].[Department].ALLMEMBERS
,[Title].[Title].[Title].ALLMEMBERS
,[Person].[Person].[Person].ALLMEMBERS
)
,[Measures].[Billable Hours]
)
,
[Measures].[Billable Hours] >= 50
)
} ON ROWS
FROM TestCube;
期望的结果是即使没有数据也仍然显示 2017 年的列,并且对于有数据的列只显示 > 50 小时。
如有任何帮助,我们将不胜感激。我确实找到了解决方法,方法是创建一个计算成员来检查小时 > 50,否则 return 为空。只是想知道是否有更好的方法来做到这一点。
谢谢, 希拉里
您可以尝试在筛选条件中添加OR ISEMPTY([Measures].[Billable Hours])
:
SELECT
[measures].[Hours] ON COLUMNS
,
[Date].[Year].[Year].ALLMEMBERS
*
{
Filter
(
NonEmpty
(
CrossJoin
(
[Client].[Client].[Client].ALLMEMBERS
,[Department].[Department].[Department].ALLMEMBERS
,[Title].[Title].[Title].ALLMEMBERS
,[Person].[Person].[Person].ALLMEMBERS
)
,[Measures].[Billable Hours]
)
,
[Measures].[Billable Hours] >= 50
OR ISEMPTY([Measures].[Billable Hours])
)
} ON ROWS
FROM TestCube;
您可以将算法移动到计算的度量中。它更快。过滤功能很慢。
with
Member [Measures].[Billable Hours 50More] as
IIF([Measures].[Billable Hours] >= 50, [Measures].[Hours], NULL)
select
[Measures].[Billable Hours 50More] on 0,
[Date].[Year].[Year].AllMembers * NonEmpty([Client].[Client].[Client].AllMembers * [Department].[Department].[Department].AllMembers * [Title].[Title].[Title].AllMembers * [Person].[Person].[Person].AllMembers, [Billable Hours 50More]) on 1
from TestCube