February 18, 2013 at 8:34 am
Hi,
I'm creating named sets in SSAS. I happen to be using 2012 but don't think that this has any effect on what i'm trying to achieve.
Essentially i have a named set that does a YTD calculation. The expression for that is here:
StrToSet("YTD([Effective Date].[Dates].[Date].[" + CStr(DATEPART("YYYY",NOW())) + "-" + Right("0" + CStr(DATEPART("m",NOW())),2) + "-" + Right("0" + CStr(DATEPART("d",NOW())),2) + "])")
This works great and show's me all the dates, 2013-01-01 to current day (2013-02-18). But this isn't what i really want (49 columns). What i want is a sum of the YTD. So instead of the attached (.png) I just want 1 column by 1 row sum total.
Is this possible or am i missing something?
Thanks,
Simon
February 18, 2013 at 9:05 am
You either need to create a member such as below and report on that
create member [Effective Date].[Dates].[YTD] As
Aggregate(
StrToSet("YTD([Effective Date].[Dates].[Date].[" + CStr(DATEPART("YYYY",NOW())) + "-"
+ Right("0" + CStr(DATEPART("m",NOW())),2) + "-"
+ Right("0" + CStr(DATEPART("d",NOW())),2) + "])")
)
or create a YTD measure such as
create member [Measures].[YTD] As
Aggregate(
StrToSet("YTD([Effective Date].[Dates].[Date].[" + CStr(DATEPART("YYYY",NOW())) + "-"
+ Right("0" + CStr(DATEPART("m",NOW())),2) + "-"
+ Right("0" + CStr(DATEPART("d",NOW())),2) + "])")
, [Measures].[Revenue])
Mack
February 18, 2013 at 9:30 am
Hi,
Thanks for your reply.
So, in SSDT (Bids for 2012) on my calculations tab I don't want a named set to achieve what i'm after?
Sorry if my question seems dim, but i'm pretty new to this stuff.
Thanks,
Simon
February 18, 2013 at 9:49 am
No, you don't just want a set
You have two real options here
Option 1 is creating measures such as Gross Revenue YTD, Net Revenue YTD etc (depending on the measure you have)
An example from one of my cubes is just to create lots of measures such as
CREATE MEMBER CURRENTCUBE.[Measures].[Net Revenue YTD]
AS
SUM(PERIODSTODATE([Date].[Date Hierarchy].[Year],[Date].[Date Hierarchy].CurrentMember)
,[Measures].[Net Revenue])
,FORMAT_STRING = "#,#.00"
,VISIBLE = 1;
The other slightly more complicated option is to create a dimension not linked to your data with you time calcs in it (query that just returns YTD, MTD etc)
You can then use a SCOPE statement to define the value of each member of the Time Calcs dimension such as
SCOPE ([Time Calcs].[Calc Name].&[YTD]);
THIS =
SUM(PERIODSTODATE([Date].[Date Hierarchy].[Year],[Date].[Date Hierarchy].CurrentMember)
,[Time Calcs].[Calc Name].[All] );
END SCOPE;
Option 2 probably needs more explaination (try http://www.bidn.com/blogs/Qazafi/ssas/1020/an-other-example-of-calculation-dimension) and I personally prefer option 1 anyway
Shout if I've lost you
Mack
February 18, 2013 at 10:30 am
Hi,
I'm sort of with you. It might help if I give a bit more context to what i'm doing....
I'm creating a cube to duplicate a pro clarity solution. Essentially i'm recreating the same thing but the client tool will now be excel and not pro clarity.
As i understand it in pro clarity there are named sets that have been created such as "YTD Current date" which today would give the sum value of their measures from 2013-01-01 to 2013-02-18. They could select any one of about 12 measures. So i've created the set as per my first post, which gives the output as per the screenshot. The thing is there is also a named set that's called "YTD Current date (previous year)" which would give the sum of the selected measure for the period 2012-01-01 to 2012-02-18 (the same period 12 months earlier). So using the named set i've created it's easy to use parallel period to go back one year. I can do that no problem.
My issue is with the output. Ideally all i wanted was a 1 row 1 column output but instead i get a no. of columns depending on the no. of days that have passed so far this year. I think pro clarity produces the 1 row 1 column output but can't confirm this until Friday.
So my options are the dimension with no relationships or calculating lots of measures....?
Thanks,
Simon
February 19, 2013 at 4:37 am
Ahhh - ProCalrity won't be giving you one row but ProClarity does allow you to sum across a set if you put it in the background and combine items (this can lead to slow queries tho). However I don't think that you can do this in Excel so you will need to find another way of doing it
I, personally, would create YTD, Prior YTD measures unless the list of measures you have is huge
Mack
February 19, 2013 at 4:40 am
It's not huge, just inconvenient. I found out about the limitation of totalling and sets in Excel the other week. Frustrating to say the least.
Oh well, thanks for all your help. I'm just glad i seem to be understanding this stuff!
Thanks,
Simon
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply