dbTalk Databases Forums  

Question about calculated members

microsoft.public.sqlserver.olap microsoft.public.sqlserver.olap


Discuss Question about calculated members in the microsoft.public.sqlserver.olap forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
John the novice
 
Posts: n/a

Default 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

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.