Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Named sets in SSAS Expand / Collapse
Author
Message
Posted Monday, February 18, 2013 8:34 AM
Say Hey Kid

Say Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey Kid

Group: General Forum Members
Last Login: Today @ 9:02 AM
Points: 702, Visits: 2,171
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




MCSA: SQL Server 2012
Follow me on Twitter: @WazzTheBadger
LinkedIn Profile: Simon Osborne


  Post Attachments 
49cols.png (4 views, 8.54 KB)
Post #1421245
Posted Monday, February 18, 2013 9:05 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, January 13, 2014 7:34 AM
Points: 117, Visits: 499
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
Post #1421254
Posted Monday, February 18, 2013 9:30 AM
Say Hey Kid

Say Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey Kid

Group: General Forum Members
Last Login: Today @ 9:02 AM
Points: 702, Visits: 2,171
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




MCSA: SQL Server 2012
Follow me on Twitter: @WazzTheBadger
LinkedIn Profile: Simon Osborne
Post #1421273
Posted Monday, February 18, 2013 9:49 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, January 13, 2014 7:34 AM
Points: 117, Visits: 499
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
Post #1421284
Posted Monday, February 18, 2013 10:30 AM
Say Hey Kid

Say Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey Kid

Group: General Forum Members
Last Login: Today @ 9:02 AM
Points: 702, Visits: 2,171
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




MCSA: SQL Server 2012
Follow me on Twitter: @WazzTheBadger
LinkedIn Profile: Simon Osborne
Post #1421297
Posted Tuesday, February 19, 2013 4:37 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, January 13, 2014 7:34 AM
Points: 117, Visits: 499
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
Post #1421551
Posted Tuesday, February 19, 2013 4:40 AM
Say Hey Kid

Say Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey Kid

Group: General Forum Members
Last Login: Today @ 9:02 AM
Points: 702, Visits: 2,171
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




MCSA: SQL Server 2012
Follow me on Twitter: @WazzTheBadger
LinkedIn Profile: Simon Osborne
Post #1421552
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse