I want to be able to create a report in which you provide a Store Key as a parameter and it will create a table of only that store's sales. For this I have created a parameter called "StoreKey" and a Query which provides the Data Set as:
"SELECT NON EMPTY {
[Measures].[Quantity] -- NOTE there are many more columns in reality
} ON COLUMNS,
NON EMPTY {
(
[Dim Date].[Calender].[Date].[2014-11-20]:[Dim Date].[Calender].[Date].[2014-11-30]
)
} on rows
FROM [cube]
WHERE WHERE ( STRTOMEMBER("[Dim Store2].[Store Key].&["+ @StoreKey + "]",CONSTRAINED))
but this provides me the error regarding the =
sign in the beginning of the Query (I have tested a plethora of different techniques such as STRTOMEMBER
, STRTOSET
etc. but none seem to work)
This data set will be used to create a table, where I group on Weeks
and then on Dates
in such a way that when you press on a date, a Drill through report is created with more detailed data for that day and store.
I want the subreport to be generated using StoreKey
and the Date
used to open up the Drill through report. I want the StoreKey
parameter to have the same values in the Main report and subreport.
For the latter I configured a Action
to create a new report in the main report, which should use the StoreKey
variable along with the Date
variable to generate the new report.
In my Subreport
I want to create the first Data set like this:
SELECT
NON EMPTY {
[Measures].[Quantity]
, [Measures].[Total Price]
, [Measures].[Contribution Margin]
, [Measures].[Profit Margin]
} ON COLUMNS,
NON EMPTY {
(
[Dim Time].[Open Hour Bucket].[Open Hour Bucket].ALLMEMBERS
, [Dim Product2].[Product Group].[Product Group].ALLMEMBERS
, [Dim Product2].[Summary].[Summary].ALLMEMBERS
)
} ON ROWS
FROM [DSV_FactStoreSales 1]
WHERE ( STRTOMEMBER("[Dim Store2].[Store Key].&["+ @StoreKey + "]",CONSTRAINED))
But then SSRS tells me that it can't be understood if I use MDX or DAX.
I hope this is not a too broad question, but I've tried to get this to work for so many, many hours so hopefully I can get a push into the right direction. It's so confusing - sometimes forum users says one should use StrToMember
and sometimes Parameters!StoreKey.value
.
I make all this testing in SSRS in Visual Studios using the Preview option. The variable StoreKey
in the Main Report
is Shown, the StoreKey
and Date
in the Generated drill through report
is internal. I have tested using different values at Default values
, available values
etc. At the moment I have set as None
.
EDIT:
I finally got a code which actually "works", like this:
SELECT
NON EMPTY
{
[Measures].[Quantity]
,[Measures].[Total Price]
,[Measures].[Contribution Margin]
,[Measures].[Profit Margin]
} ON COLUMNS,
NON EMPTY
{
(
[Dim Date].[Calender].[Date].[2014-11-20]:[Dim Date].[Calender].[Date].[2014-11-30])
,STRTOMEMBER("[Dim Store2].[Store Key].&[" + @StoreKey + "]")
} on rows
from [DSV_FactStoreSales 1]
My issue is however, if I copy this statement into Management studios and replace the variable expression with a hard coded value, like this:
STRTOMEMBER('[Dim Store2].[Store Key].&[1024]')
I get an error that the hierarchies of the dimensions must match, therefor I adjust the code to:
NON EMPTY { ([Dim Date].[Calender].[Date].[2014-11-20]:[Dim Date].[Calender].[Date].[2014-11-30]
,STRTOMEMBER('[Dim Store2].[Store Key].&[1024]'))} on rows
which returns a set. However, using the original Edited code in SSRS provides no Error in the Query designer , however, when I want to preview the Project I get an error of non matching hiearchies. I then proceed to make the adjustments I did in Management studios , (but using a variable instead of a hard coded value), but then I get an empty set in SSRS, which gives various errors as I try to call an empty data set in my table.
Be sure your dataset is mapped to a SSRS parameter.
Also in the Query Command Text
expression use your MDX expression without =
, it is not a SSRS expression:
You have an error in your WHERE
clause:
WHERE ( STRTOMEMBER("[Dim Store2].[Store Key].&["+@StoreKey+"],CONSTRAINED)",
STRTOMEMBER("[Dim Date].[Date Key].&["+@Date+"],CONSTRAINED" )
It should be:
WHERE ( STRTOMEMBER("[Dim Store2].[Store Key].&["+ @StoreKey + "]",CONSTRAINED),
STRTOMEMBER("[Dim Date].[Date Key].&[" + @Date + "]",CONSTRAINED ))
UPDATE: Try setting the MDX expression from the Query Command Text window.
This works for me as intended.
Avoid using SS Management Studio since you can't set SSRS parameters from there.
Hope it helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.