MDX参数传递
0
各位老师,请问在MDX中时间参数如何传递?为神马老是提示问题呢
1、不带参数,代码运行成功:
WITH
MEMBER [Measures].[Amount_D] AS
[Measures].[Amount] --当日销量
MEMBER [Measures].[Amount_M] AS
SUM(MTD([Dim Date].[Y-M-D].[Date Key].&[2015-10-21T00:00:00]),[Measures].[Amount]) --本月累计销量
SELECT
NON EMPTY
{ [Measures].[Amount_D], [Measures].[Amount_M] } ON 0,
NON EMPTY
{ ([Dim Department].[Department].[Department].ALLMEMBERS * [Dim City].[City].[City].ALLMEMBERS ) } ON 1
FROM [CE Sales DW]
where [Dim Date].[Y-M-D].[Date Key].&[2015-10-21T00:00:00]
运行结果:
2、将时间维度改为参数,代码运行失败(加粗的地方为改动):
WITH
MEMBER [Measures].[Amount_D] AS
[Measures].[Amount] --当日销量
MEMBER [Measures].[Amount_M] AS
SUM(MTD(StrToMember("[Dim Date].[Y-M-D].[Date Key].&[" + Format(cdate(@key),"YYYY-MM-DD") + "T00:00:00]")),[Measures].[Amount]) --本月累计销量
SELECT
NON EMPTY
{ [Measures].[Amount_D], [Measures].[Amount_M] } ON 0,
NON EMPTY
{ ([Dim Department].[Department].[Department].ALLMEMBERS * [Dim City].[City].[City].ALLMEMBERS ) } ON 1
FROM [CE Sales DW]
where StrToMember("[Dim Date].[Y-M-D].[Date Key].&[" + Format(cdate(@key),"YYYY-MM-DD") + "T00:00:00]")
运行提示:
参数key的设置:
请问各位老师,是Format函数的使用有问题吗?
1、不带参数,代码运行成功:
WITH
MEMBER [Measures].[Amount_D] AS
[Measures].[Amount] --当日销量
MEMBER [Measures].[Amount_M] AS
SUM(MTD([Dim Date].[Y-M-D].[Date Key].&[2015-10-21T00:00:00]),[Measures].[Amount]) --本月累计销量
SELECT
NON EMPTY
{ [Measures].[Amount_D], [Measures].[Amount_M] } ON 0,
NON EMPTY
{ ([Dim Department].[Department].[Department].ALLMEMBERS * [Dim City].[City].[City].ALLMEMBERS ) } ON 1
FROM [CE Sales DW]
where [Dim Date].[Y-M-D].[Date Key].&[2015-10-21T00:00:00]
运行结果:
2、将时间维度改为参数,代码运行失败(加粗的地方为改动):
WITH
MEMBER [Measures].[Amount_D] AS
[Measures].[Amount] --当日销量
MEMBER [Measures].[Amount_M] AS
SUM(MTD(StrToMember("[Dim Date].[Y-M-D].[Date Key].&[" + Format(cdate(@key),"YYYY-MM-DD") + "T00:00:00]")),[Measures].[Amount]) --本月累计销量
SELECT
NON EMPTY
{ [Measures].[Amount_D], [Measures].[Amount_M] } ON 0,
NON EMPTY
{ ([Dim Department].[Department].[Department].ALLMEMBERS * [Dim City].[City].[City].ALLMEMBERS ) } ON 1
FROM [CE Sales DW]
where StrToMember("[Dim Date].[Y-M-D].[Date Key].&[" + Format(cdate(@key),"YYYY-MM-DD") + "T00:00:00]")
运行提示:
参数key的设置:
请问各位老师,是Format函数的使用有问题吗?
没有找到相关结果
重要提示:提问者不能发表回复,可以通过评论与回答者沟通,沟通后可以通过编辑功能完善问题描述,以便后续其他人能够更容易理解问题.
2 个回复
天桥下的郑成功 - Hadoop大数据开发工程师、数仓架构师、熟悉数据仓库设计、Hadoop、Spark、HBase、Hive、SSIS等开发 2015-12-21 回答
赞同来自:
ChrisPo 2015-12-21 回答
赞同来自: