1
votes

can anyone tell me how to use SSRS parameter here? I am using SSAS as the datasource, the report displays everything fine except i want to filter the results based on the parameter value.

SELECT NON EMPTY { [Measures].[Count of ID], [Measures].[Average of Amount] } ON COLUMNS, NON EMPTY { (STRTOMEMBER(@Region,CONSTRAINED) * [Query].[State].[State].ALLMEMBERS ) } DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS FROM [Model] CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS

the parameter is @Region in the report.

1

1 Answers

4
votes

The easiest way is when you set up your DataSet, to use the QueryDesigner to pull back what you want from SSAS. When you specify your dimension filters, on the far right is a checkbox under the heading "Parameter". Check this, and it will automagically generate the SSRS parameter for you.

That'll create a parameter expecting a value like the following, which is actually a Dimension filter:

\[DimensionName\].\[AttributeName\].&\[Value\]

If you need to do it manually via MDX though, looking at your MDX expression, it looks to me (in my very limited MDX experience - still learning) that you're attempting to specify your parameter (filter) in your ROWS, rather than applying it in the FROM clause.

I would expect that it might be something more like this?:

SELECT 
NON EMPTY { [Measures].[Count of ID], [Measures].[Average of Amount] } ON COLUMNS
,NON EMPTY { ([DimensionName].[AttributeName].ALLMEMBERS * [Query].[State].[State].ALLMEMBERS ) } DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS 
FROM 
(SELECT (STRTOSET(@Region,CONSTRAINED) ON COLUMNS FROM [Model])
WHERE ( IIF( STRTOSET(@Region, CONSTRAINED).Count = 1, STRTOSET(@Region, CONSTRAINED), [DimensionName].[AttributeName].currentmember ) ) CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS

Replacing DimensionName and AttributeName with your actual values from your cube definition. This assumes that your @Region parameter is in the same format as the one I specified above. If not, you can substitute the rest of the syntax in your DataSet properties when you assign your report parameter to the DataSet.

Apologies if this doesn't work, I'm working off a limited knowledge of MDX at the moment, but I figured a partial answer is better than none at all, right?