dbTalk Databases Forums  

Sum Sales for Current year, independent of time dimension usage

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


Discuss Sum Sales for Current year, independent of time dimension usage in the microsoft.public.sqlserver.olap forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Einar Nęss
 
Posts: n/a

Default Sum Sales for Current year, independent of time dimension usage - 05-02-2006 , 07:43 AM






My time dimension has two hierarchies, year-month-day and year-week-day. I
want to sum the sales ([measures].[sales]) from 1.1.<current year> to
<today>.

YTD() is dependent on a time dimension and would limit/extend the sum to
last day in selected member. I want my sum to be independent of time
dimension usage and base calculations on actual date the day the query is
issued.

Anyone who has the MDX syntax/solution for this?

Best regards
Einar N.



Reply With Quote
  #2  
Old   
Tim Dot NoSpam
 
Posts: n/a

Default Re: Sum Sales for Current year, independent of time dimension usage - 05-04-2006 , 06:24 PM






Einar,

Do you have access to the date passed in as the "to date"? If so, you could
write a custom date set and use that as your time slicer.

Assuming your date has the format YYYY-MM-DD:

/*
* Create a set of dates from current year + '-01-01' (Jan 01, cy) to
* date passed in (assuming current year).
*
*/
WITH SET [TimeSet] as
'{
StrToMember
(
"[Time].[HierarchyName].&[" &
CStr( DatePart("y", VBA!Now)) & "-" & "01-01]"
):
StrToMember
(
toDateParam
)
}'
SELECT
{ [Dimension].[Hierarchy].[Members] } ON COLUMNS,
{ [TimeSet], [Measures].[sales] } ON ROWS
FROM [yourCube]

I've used this method in reporting services with success. I'm sure Mosha or
one of the other gurus may have a better method for you. I'm a little weak
on the basic stuff (head, tail, descendants, etc)...


"Einar Nęss" <einar.naess.remove (AT) this (DOT) hands.no> wrote

Quote:
My time dimension has two hierarchies, year-month-day and year-week-day. I
want to sum the sales ([measures].[sales]) from 1.1.<current year> to
today>.

YTD() is dependent on a time dimension and would limit/extend the sum to
last day in selected member. I want my sum to be independent of time
dimension usage and base calculations on actual date the day the query is
issued.

Anyone who has the MDX syntax/solution for this?

Best regards
Einar N.




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.