Hi,
I have only recently started playing around with Reporting Services (2005), and I am having some problems creating a basic report.
What I want to display is a table which shows product names in the first column, sales for a specific period this year in the second column, and sales for the same period last year in the third column. The 'specific period' is determined by specifying a start week and an end week which I have set up as parameters.
I have managed to produce the first 2 column with no trouble. However, for the third column I need to subtract 52 weeks from the parameters and use them as new parameter in the third column.
Can anyone offer any suggestions?
Dave
Sounds like a T-SQL issue. Do you have a sample of the query?|||My apologies, I just realised I neglected to mention that the source data was in a cube. What I have in the cube is a product dimension, a time dimension (which goes down to week level), and a measure for sales amount.|||Anybody got any ideas?|||
In MDX I would suggest using ParallelPeriod. The following is an AdventureWorks query showing an example. You just need to replace the expicit time members with parameters:
WITH
MEMBER [Measures].[Selection] as '
Sum(
[Date].[Calendar].[Month].&[2003]&[1]
:
[Date].[Calendar].[Month].&[2003]&[5]
, [Measures].[Sales Amount]
)'
MEMBER [Measures].[SamePeriodLastYear] as '
Sum(
ParallelPeriod([Date].[Calendar].[Calendar Year], 1, [Date].[Calendar].[Month].&[2003]&[1])
:
ParallelPeriod([Date].[Calendar].[Calendar Year], 1, [Date].[Calendar].[Month].&[2003]&[5])
, [Measures].[Sales Amount]
)'
SELECT
{ [Measures].[Selection]
, [Measures].[SamePeriodLastYear]
} ON 0,
NON EMPTY [Product].[Product Categories].Members ON 1
FROM [Adventure Works]
|||Thanks very much, that works a treat.|||
Ok,
I managed to get the MDX query working in SQL Studio but when I try to parameterize it in Reporting Services, I don't get any rows returned.
I have created 2 parameters (StartWeek + EndWeek) which are both integers, and have used these in 2 calculated fields. The code for these is:
ThisYear
Sum(
[Dim Week No].[Week No].&[@.StartWeek]
:
[Dim Week No].[Week No].&[@.EndWeek]
, [Measures].[Rate]
)
LastYear
Sum(
ParallelPeriod([Dim Week No].[Week in Year].[Year Name], 1,[Dim Week No].[Week in Year].[Week No].&[@.StartWeek] )
:
ParallelPeriod([Dim Week No].[Week in Year].[Year Name], 1,[Dim Week No].[Week in Year].[Week No].&[@.EndWeek] )
, [Measures].[Rate]
)
I have then just added these 2 fields, and the product field to my report's dataset. Could somebody please tell me where I am going wrong as this is driving me crazy!!
Dave
|||
Ok,
I managed to get the MDX query working in SQL Studio but when I try to parameterize it in Reporting Services, I don't get any rows returned.
I have created 2 parameters (StartWeek + EndWeek) which are both integers, and have used these in 2 calculated fields. The code for these is:
ThisYear
Sum(
[Dim Week No].[Week No].&[@.StartWeek]
:
[Dim Week No].[Week No].&[@.EndWeek]
, [Measures].[Rate]
)
LastYear
Sum(
ParallelPeriod([Dim Week No].[Week in Year].[Year Name], 1,[Dim Week No].[Week in Year].[Week No].&[@.StartWeek] )
:
ParallelPeriod([Dim Week No].[Week in Year].[Year Name], 1,[Dim Week No].[Week in Year].[Week No].&[@.EndWeek] )
, [Measures].[Rate]
)
I have then just added these 2 fields, and the product field to my report's dataset. Could somebody please tell me where I am going wrong as this is driving me crazy!!
Dave
|||
Ok,
I managed to get the MDX query working in SQL Studio but when I try to parameterize it in Reporting Services, I don't get any rows returned.
I have created 2 parameters (StartWeek + EndWeek) which are both integers, and have used these in 2 calculated fields. The code for these is:
ThisYear
Sum(
[Dim Week No].[Week No].&[@.StartWeek]
:
[Dim Week No].[Week No].&[@.EndWeek]
, [Measures].[Rate]
)
LastYear
Sum(
ParallelPeriod([Dim Week No].[Week in Year].[Year Name], 1,[Dim Week No].[Week in Year].[Week No].&[@.StartWeek] )
:
ParallelPeriod([Dim Week No].[Week in Year].[Year Name], 1,[Dim Week No].[Week in Year].[Week No].&[@.EndWeek] )
, [Measures].[Rate]
)
I have then just added these 2 fields, and the product field to my report's dataset. Could somebody please tell me where I am going wrong as this is driving me crazy!!
Dave
|||
Ok,
I managed to get the MDX query working in SQL Studio but when I try to parameterize it in Reporting Services, I don't get any rows returned.
I have created 2 parameters (StartWeek + EndWeek) which are both integers, and have used these in 2 calculated fields. The code for these is:
ThisYear
Sum(
[Dim Week No].[Week No].&[@.StartWeek]
:
[Dim Week No].[Week No].&[@.EndWeek]
, [Measures].[Rate]
)
LastYear
Sum(
ParallelPeriod([Dim Week No].[Week in Year].[Year Name], 1,[Dim Week No].[Week in Year].[Week No].&[@.StartWeek] )
:
ParallelPeriod([Dim Week No].[Week in Year].[Year Name], 1,[Dim Week No].[Week in Year].[Week No].&[@.EndWeek] )
, [Measures].[Rate]
)
I have then just added these 2 fields, and the product field to my report's dataset. Could somebody please tell me where I am going wrong as this is driving me crazy!!
Dave
|||
Ok,
I managed to get the MDX query working in SQL Studio but when I try to parameterize it in Reporting Services, I don't get any rows returned.
I have created 2 parameters (StartWeek + EndWeek) which are both integers, and have used these in 2 calculated fields. The code for these is:
ThisYear
Sum(
[Dim Week No].[Week No].&[@.StartWeek]
:
[Dim Week No].[Week No].&[@.EndWeek]
, [Measures].[Rate]
)
LastYear
Sum(
ParallelPeriod([Dim Week No].[Week in Year].[Year Name], 1,[Dim Week No].[Week in Year].[Week No].&[@.StartWeek] )
:
ParallelPeriod([Dim Week No].[Week in Year].[Year Name], 1,[Dim Week No].[Week in Year].[Week No].&[@.EndWeek] )
, [Measures].[Rate]
)
I have then just added these 2 fields, and the product field to my report's dataset. Could somebody please tell me where I am going wrong as this is driving me crazy!!
Dave
|||
Ok,
I managed to get the MDX query working in SQL Studio but when I try to parameterize it in Reporting Services, I don't get any rows returned.
I have created 2 parameters (StartWeek + EndWeek) which are both integers, and have used these in 2 calculated fields. The code for these is:
ThisYear
Sum(
[Dim Week No].[Week No].&[@.StartWeek]
:
[Dim Week No].[Week No].&[@.EndWeek]
, [Measures].[Rate]
)
LastYear
Sum(
ParallelPeriod([Dim Week No].[Week in Year].[Year Name], 1,[Dim Week No].[Week in Year].[Week No].&[@.StartWeek] )
:
ParallelPeriod([Dim Week No].[Week in Year].[Year Name], 1,[Dim Week No].[Week in Year].[Week No].&[@.EndWeek] )
, [Measures].[Rate]
)
I have then just added these 2 fields, and the product field to my report's dataset. Could somebody please tell me where I am going wrong as this is driving me crazy!!
Dave
|||
Try constructing a MemberUniqueName string and passing that to the StrToMember functiuon
Sum(
StrToMember("[Dim Week No].[Week No].&[" + CStr(@.StartWeek) + "] ", CONSTRAINED)
:
StrToMember("[Dim Week No].[Week No].&[" + CStr(@.EndWeek) + "] ", CONSTRAINED)
, [Measures].[Rate]
)
|||
Hi Adam,
Again, that works fine in SQL Studio with integer values instead of the parameters. However, when I try it in Reporting Services with my parameters I get the following error:
"The 'ThisYear' calculated member cannot be created because of the following error: Parser: The StartWeek parameter could not be resolved because it was referenced in ann inner subexpression"
My calculated member field is now:
"Sum(
StrToMember("[Dim Week No].[Week in Year].[Week No].&[" + CStr(@.StartWeek) + "] ", CONSTRAINED)
:
StrToMember("[Dim Week No].[Week in Year].[Week No].&[" + CStr(@.EndWeek) + "] ", CONSTRAINED)
, [Measures].[Rate]
)"
|||
Some options:
try removing the CStr() call and see if that works
OR