Question about calculated members -
11-08-2004
, 05:00 AM
I have the following calculated member which calculates a year to date value.
The month dimension contains two levels - Year and Month
iif ([Month].currentmember.name =
"May",sum(lastperiods(1,[Month].currentmember),[Measures].[Hours]),
iif ([Month].currentmember.name =
"June",sum(lastperiods(2,[Month].currentmember),[Measures].[Hours]),
iif ([Month].currentmember.name =
"July",sum(lastperiods(3,[Month].currentmember),[Measures].[Hours]),
iif ([Month].currentmember.name =
"August",sum(lastperiods(4,[Month].currentmember),[Measures].[Hours]),
iif ([Month].currentmember.name =
"September",sum(lastperiods(5,[Month].currentmember),[Measures].[Hours]),
iif ([Month].currentmember.name =
"October",sum(lastperiods(6,[Month].currentmember),[Measures].[Hours]),
iif ([Month].currentmember.name =
"November",sum(lastperiods(7,[Month].currentmember),[Measures].[Hours]),
iif ([Month].currentmember.name =
"December",sum(lastperiods(8,[Month].currentmember),[Measures].[Hours]),
iif ([Month].currentmember.name =
"January",sum(lastperiods(9,[Month].currentmember),[Measures].[Hours]),
iif ([Month].currentmember.name =
"February",sum(lastperiods(10,[Month].currentmember),[Measures].[Hours]),
iif ([Month].currentmember.name =
"March",sum(lastperiods(11,[Month].currentmember),[Measures].[Hours]),
iif ([Month].currentmember.name =
"April",sum(lastperiods(12,[Month].currentmember),[Measures].[Hours]),
iif (left([Month].currentmember.level.name,4) = "Year",
iif ( isempty(sum(lastperiods(-12,[Month].firstchild),[Measures].[YTD]))
,null,0),
iif (left([Month].currentmember.level.name,4) = "(All" ,
null,4))
))))))))))))
The problem I have is with the "Total" values in that the value shown was
always 0 . I tracked the problem down to the fact that the "Year" "Total" was
summing up the whole year's values
iif ( isempty(sum(lastperiods(-12,[Month].firstchild),[Measures].[YTD]))
,null,0),
The above line of code was ignoring what months the user had selected to
view and was therefore including all rows .
Ie: the user is showing months june and july but the user is seeing all rows
providing there are values for any month of the year.
What I want to do is to change so as to only give totals for the months the
user has selected.
Any ideas ?
Thanks in advance,
John |