3

In my MDX report based on cube, the input help for date must be a calendar, therefore Date/Time type of parameter is essential. The field in time dimension by which I filter data is Integer. Example value: 20130827.

My dataset query looks like this:

 SELECT NON EMPTY { [Measures].[Hours In Track] } ON COLUMNS, NON EMPTY {
 ([Dim Date].[Date ID].[Date ID].ALLMEMBERS * [Dim Division].[Hierarchy].[Division ID].ALLMEMBERS ) }
 DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS FROM
 ( SELECT ( STRTOSET(@DimDivisionHierarchy, CONSTRAINED) ) ON COLUMNS FROM
 ( SELECT ( STRTOMEMBER(@FromDimDateDateID, CONSTRAINED) : STRTOMEMBER(@ToDimDateDateID, CONSTRAINED) ) ON COLUMNS FROM [BicepsArveCube]))
 CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS

I used a text field, which showed me, that date/time type parameter value looks as follows: 2013-08-05 00:00:00, while my DateID is Integer type, so I need to do conversion.

When in dataset parameters tab I specify the parameter value as expression:

="[Dim Date].[Date ID].&["
 & Replace(Replace("2013-08-05 00:00:00", "-", ""), " 00:00:00", "")
 & "]"

I get the data as expected, everything works fine. But when I changed the hardcoded date/time value to parameter value (type date/time ):

="[Dim Date].[Date ID].&["
 & Replace(Replace(Parameters!FromDimDateDateID.Value, "-", ""), " 00:00:00", "")
 & "]"

I get a constraint violation error. I don't know why, because as written above, the Parameters!FromDimDateDateID.Value looks exactly the same as the hardcoded value I used.

I used text field to check what expression I get after conversion in both cases (hardcoded date and the same date chosen from calendar and passed as parameter value) and it looks exactly the same:

[Dim Date].[Date ID].&[20130805]
4

1 回答 1

3

尝试

STRTOMEMBER(
  "[Dim Date].[Date ID].&["
 + Replace(Replace(@FromDimDateDateID, "-", ""), " 00:00:00", "")
 + "]",
CONSTRAINED)

在 MDX(由 Analysis Services 解释)中,您无法访问 Reporting Services 对象,例如Parameters. 相反,它们的值与 MDX 语句一起发送到 Analysis Services 服务器,该语句可以使用@表示法引用它们。

于 2013-08-27T12:25:41.533 回答