3

您好我正在尝试在 MDX 查询中放置一个动态日期过滤器(如今天的日期),但我无法从查询中获得任何结果,有人可以帮助检查我的查询有什么问题吗?

我首先用指定的日期值测试了 MDX 查询,查询是

WITH MEMBER [Yesterday] AS VBAMDX.Format(VBAMDX.Now()-1,"MM/dd/yy")

select {[Measures].[Order Root Total], [Measures].[Yesterday]} on columns,
filter ([D Date].[DAY ID].&[09/19/13],
[Measures].[Order Root Total]>0) on rows
from [Root Product Profit and Sales]

它返回结果

            Order Root Total    Yesterday
09/19/13    1481.2225483463         09/19/13

然后我尝试了:

WITH MEMBER [Yesterday] AS VBAMDX.Format(VBAMDX.Now()-1,"MM/dd/yy")

select {[Measures].[Order Root Total], [Measures].[Yesterday]} on columns,
filter ([D Date].[DAY ID].&[Yesterday],
[Measures].[Order Root Total]>0) on rows
from [Root Product Profit and Sales]

然后我什么都不回。。

有人可以帮帮我吗!非常感谢!!!

4

1 回答 1

2

您必须使用StrToMember, 作为Yesterday度量,并且不能直接在成员名称中使用。我建议在[D Date].[DAY ID]层次结构上定义 Yesterday 而不是Measures一个:

WITH MEMBER [D Date].[DAY ID].[Yesterday] AS 
     StrToMember('[D Date].[DAY ID].&' + VBAMDX.Format(VBAMDX.Now()-1,"MM/dd/yy") + ']')

select {[Measures].[Order Root Total], [Measures].[Yesterday]} on columns,
filter ([D Date].[DAY ID].[Yesterday],
[Measures].[Order Root Total]>0) on rows
from [Root Product Profit and Sales]
于 2013-09-20T08:37:41.350 回答