SSRS CURRENT month and LAST year Issue
Hello Experts,
In my SSRS report, I used the following code snippet in order to find Previous week(s) sales units:
WITH
MEMBER [Measures].[W1] AS ( PARALLELPERIOD( [Dim Date].[WeeklyCalendar].[Week Of Year],1,[Dim Date].[WeeklyCalendar].CurrentMember) ,[Measures].[Sale Unit])
WITH
MEMBER [Measures].[W1] AS ( PARALLELPERIOD( [Dim Date].[WeeklyCalendar].[Week Of Year],2,[Dim Date].[WeeklyCalendar].CurrentMember) ,[Measures].[Sale Unit])
Now, I want to get the current month's total sales units. Suppose that I have picked the 2nd week of the Year 2011. I have tried the following code:
MEMBER [Measures].[MonthlySales] AS ( PARALLELPERIOD( [Dim Date].[WeeklyCalendar].[Month],0,[Dim Date].[WeeklyCalendar].CurrentMember) ,[Measures].[Sale Unit])
But it gets the wrong result.
Similarly how can I get the complete sales units of the previous year??
King Regards
January 12th, 2011 1:29pm
My date hierarchy (called WeeklyCalendar) is designed as:
Year -> Month -> WeekOfYear -> Date
And I have also tried the following:
With member [Measures].[PreviousYear] as (parallelperiod( [Dim Date].[WeeklyCalendar].[Year], 1, [Dim Date].[WeeklyCalendar].currentmember),[Measures].[Sale Unit])
I still get the previous WEEK's sale unit. Where is the mistake? Please Help
Free Windows Admin Tool Kit Click here and download it now
January 13th, 2011 4:37am
Hi,
Could you also try below demo?
with
member [Previous1] as
([Date].[Calendar].currentmember.lag(1),[Measures].[Internet Order
Quantity])
member [Previous2]
as
([Date].[Calendar].currentmember.lag(2),[Measures].[Internet Order
Quantity])
member [Current]
as
[Measures].[Internet Order Quantity]
select {[Current] , [Previous1],[Previous2]}
on 0
,[Date].[Calendar].members
on 1
from [Adventure Works]
where [Date].[Calendar Year].&[2003]
Hope this helps,
Raymond
Raymond Li - MSFT
January 14th, 2011 5:17am
I have tried your code now. And it still returns the previous week's sale units
with member [Previous1] as
([Dim Date].[WeeklyCalendar].currentmember.lag(1),[Measures].[Sale Unit])
member [Previous2] as
([Dim Date].[WeeklyCalendar].currentmember.lag(2),[Measures].[Sale Unit])
member [Current] as
[Measures].[Sale Unit]
I have picked the 2nd week of the current year. And this query returns the first week of the current year. My purpose is to get complete 2010 data as "PREVYEAR" and complete december-2010 data as "PREVMONTH" as calculated members.
Free Windows Admin Tool Kit Click here and download it now
January 14th, 2011 5:34am
I have picked the 2nd week of the current year. And this query returns the first week of the current year. My purpose is to get complete 2010 data as "PREVYEAR" and complete december-2010 data as "PREVMONTH" as calculated members.
Please give another try with this one:
with
member [Previous1] as
(ParallelPeriod ([Date].[Calendar].[Calendar Year],1,[Date].[Calendar].currentmember),[Measures].[Internet
Order Quantity])
member [Current]
as
[Measures].[Internet Order Quantity]
select {[Current] , [Previous1]}
on 0
,[Date].[Calendar].[Month]
on 1
from [Adventure Works]
where [Date].[Calendar Year].&[2003]
If it still doesn’t work, could you explain the requirement with below code?
with
member [Previous1] as
ParallelPeriod ([Date].[Calendar].[Calendar
Year],1,[Date].[Calendar].currentmember).name
member
[Current] as
[Dim Date].[WeeklyCalendar].currentmember.name
--------- output
member
current Previous1
2002
2002 2001
H1 2002
H12002 H12001
Q1 2002
Q12002 Q12001
Jan2002
Jan2002 Jan2001
… …
… …
I mean let’s check the member first, if the value of member [Current] is not what you want, could you post the expected result?
Hope this helps,
Raymond
Raymond Li - MSFT
January 14th, 2011 5:58am
I have selected the second week of 2011 and tried to apply the following one:
with member [Previous1] as
(ParallelPeriod ([Date].[Calendar].[Calendar Year],1,[Date].[Calendar].currentmember),[Measures].[Internet Order Quantity])
It returns the second week of 2010 sale units.
I have also tried the following:
with member [Previous2] as
ParallelPeriod ([Date].[Calendar].[Calendar Year],1,[Date].[Calendar].currentmember).name
and it returns just "2" .
My desired output:
- Selected week's sale unit - Previous year's TOTAL sale unit - Previous month's TOTAL sale unit.
Free Windows Admin Tool Kit Click here and download it now
January 14th, 2011 6:32am
I think I found the solution:
with member [Previous1] as
SUM(ParallelPeriod ([Dim Date].[WeeklyCalendar].[Year],1,[Dim Date].[WeeklyCalendar].currentmember.parent.parent),[Measures].[Sale Unit])
This code gets the cumulative value of sale units of previous year. Because of my dimDate dimension hierarchy is designed like
Year -> Month-> WeekNumber > Date
I always select weeknumbers from the filters. So currentmember.parent.parent statement solved the problem
January 14th, 2011 9:37am