我对这整个MDX查询都很新。我有以下查询,我试图执行,但不断收到以下错误:
执行查询... Query(19,16)STRTOSET函数需要1参数的字符串或数字表达式。使用元组集表达式。 执行完成
我的查询如下:
SELECT
NON EMPTY { [Measures].[Effective Duration] } ON COLUMNS,
NON EMPTY { (
[Dim Cause Code].[Cause].[Cause].ALLMEMBERS *
[Dim Classification].[Classification].[Classification].ALLMEMBERS *
[Dim Date 1].[Full Date Alternate Key].[Full Date Alternate Key].ALLMEMBERS *
[Dim Location 1].[Work Center Name].[Work Center Name].ALLMEMBERS *
[Fact Process Downtime].[Start Datetime].[Start Datetime].ALLMEMBERS *
[Fact Process Downtime].[End Datetime].[End Datetime].ALLMEMBERS *
[Fact Process Downtime].[Id].[Id].ALLMEMBERS )
} DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS FROM (
SELECT ( STRTOSET({[Fact Process Downtime].[Is Virtual].&[False]}, CONSTRAINED) ) ON COLUMNS
FROM (
SELECT ( STRTOSET({[Dim Location 1].[Work Center].&[South32 Manganese.Mamatwan.DMS]}, CONSTRAINED) ) ON COLUMNS
FROM (
SELECT ( STRTOSET({[Dim Classification].[Classification].&[Scheduled Process]}, CONSTRAINED) ) ON COLUMNS
FROM (
SELECT ( STRTOSET({[Dim Date 1].[Month Fiscal Year].&[Jul/17]}, CONSTRAINED) ) ON COLUMNS FROM [FactDownTime])))) WHERE (
IIF( STRTOSET({[Dim Date 1].[Month Fiscal Year].&[Jul/17]}, CONSTRAINED).Count = 1, STRTOSET({[Dim Date 1].[Month Fiscal Year].&[Jul/17]}, CONSTRAINED), [Dim Date 1].[Month Fiscal Year].currentmember ),
IIF( STRTOSET(STRTOSET({[Dim Location 1].[Work Center].&[South32 Manganese.Mamatwan.DMS]}, CONSTRAINED).Count = 1, STRTOSET(STRTOSET({[Dim Location 1].[Work Center].&[South32 Manganese.Mamatwan.DMS]}, CONSTRAINED), [Dim Location 1].[Work Center].currentmember ),
IIF( STRTOSET({[Fact Process Downtime].[Is Virtual].&[False]}, CONSTRAINED).Count = 1, STRTOSET({[Fact Process Downtime].[Is Virtual].&[False]}, CONSTRAINED), [Fact Process Downtime].[Is Virtual].currentmember )
)))
答案 0 :(得分:3)
你需要为这个函数提供字符串strToSet是" String to Set"
的缩写https://msdn.microsoft.com/en-us/library/ms144782.aspx
所以这是不正确的:
STRTOSET({[Fact Process Downtime].[Is Virtual].&[False]}, CONSTRAINED)
但这是正确的
STRTOSET('{[Fact Process Downtime].[Is Virtual].&[False]}', CONSTRAINED))
strToSet函数的主要用例是将参数传递到来自SSRS
的mdx查询时,因此很少使用这样的语法:
STRTOSET('{[Fact Process Downtime].[Is Virtual].&[False]}', CONSTRAINED))
如果不涉及参数,那么只需摆脱STRTOSET:
{[Fact Process Downtime].[Is Virtual].&[False]}
如果您需要使用参数,请查看@ alejandrozuleta最近的优秀答案:
MDX SSRS Parameter category chooses all sub category
如果参数不重要,那么您的脚本可能会简化为以下内容:
SELECT
NON EMPTY [Measures].[Effective Duration] ON 0,
NON EMPTY
[Dim Cause Code].[Cause].[Cause].ALLMEMBERS *
[Dim Classification].[Classification].[Classification].ALLMEMBERS *
[Dim Date 1].[Full Date Alternate Key].[Full Date Alternate Key].ALLMEMBERS *
[Dim Location 1].[Work Center Name].[Work Center Name].ALLMEMBERS *
[Fact Process Downtime].[Start Datetime].[Start Datetime].ALLMEMBERS *
[Fact Process Downtime].[End Datetime].[End Datetime].ALLMEMBERS *
[Fact Process Downtime].[Id].[Id].ALLMEMBERS
ON 1
FROM
(
SELECT
[Fact Process Downtime].[Is Virtual].&[False] ON 0,
[Dim Location 1].[Work Center].&[South32 Manganese.Mamatwan.DMS] ON 1,
[Dim Classification].[Classification].&[Scheduled Process] ON 2,
[Dim Date 1].[Month Fiscal Year].&[Jul/17] ON 3
FROM [FactDownTime]
);