Showing posts with label ssas. Show all posts
Showing posts with label ssas. Show all posts

Wednesday, March 28, 2012

New to MDX. Help Needed with a Calculation Definition in my SSAS 2005 Cube

I'm new to MDX and I don't quite get the hang of it yet, so I'll try to provide all of the relevant information that I can so that you guys can help me.

My company has a lot of "Rolling 12 Month" metrics and I've been able to incorporate all but a few in my SSAS 2005 cube. By "Rolling 12", we refer to the 12-month period that ends with the previous month. So all "Rolling 12" metrics reviewed in December 2005 refer to the period of December 2004 through November 2005.

So for "Rolling 12 Month Invoices", I have the following calculation defined in my cube and it seems to be correct:

SUM( LASTPERIODS ( 12, [Invoice Date].[Invoice Month]), [Measures].[Invoice $])

Now I'm having trouble defining the # of customers in the Rolling 12 month period. I added a DistinctCount measure for # of customers and have been able to use it in the definition of 2 other metrics.

For example, for the # of customers for 2004, I have it defined as:

([Measures].[# of Customers] , [Invoice Date].[Invoice Year].&[2004])

And it appears to fine.

I tried similar variation of the following with no luck:

SUM(SUM( LASTPERIODS ( 12, [Invoice Date].[Invoice Month]), [Measures].[# of Customers]))

Your help is greatly appreciated!

EDIT: I'm using SQL Server 2005 Standard Edition
EDIT: Please let me know what other details you may need about my cube.A Distinct Count measure isn't strictly additive, so try Aggregate() rather than
Sum() to compute it over a set (only works with AS 2005):

>>
Aggregate(LASTPERIODS ( 12, [Invoice Date].[Invoice Month]),
[Measures].[# of Customers])
>>
http://msdn2.microsoft.com/en-us/library/ms145524(en-US,SQL.90).aspx
>>

Aggregate (MDX)

Returns a scalar value calculated by aggregating either measures or an optionally specified numeric expression over the tuples of a specified set.
...

Distinct Count

An aggregation across the fact data contributing to the subcube when the slicer axis includes a set.

Calculations on the set generate an error. Calculations below granularity of the set are ignored.

...
>>

|||Thank you very much!!! Big Smile

Monday, March 12, 2012

New partition (SSAS 2005) - named query not in "available tables"

I'm trying to create another partition in an existing measure group.
I start the new partition wizard and choose my data source view in the
"Look in", and then click "Find tables".
My named query does not appear in the list. What could be wrong?

I have saved and refreshed the data source view. The named query has the
same column names and data types that the original table has (that the
measure group is using now).

I also tried to make the named query a ordinary view in the source
database but that does not appear in the list either (I choose the
data source then instead of the data source view).

Hi,

I wouldn't suspect that you'd see a named query in the list of tables when you go to create a new partition. I'm not sure if that list of tables shows views from the underlying DB, either..But, you can make your partition query binding, instead of table binding, and you can make the partition source the same query you're using in your named query, or a subset of it with a where clause, or whatever you choose.

HTH,
C
|||

I don't understand...

In the "New partition wizard" there isn't a whole lot to choose from... Pick either a data source or a data source view, and then pick the "table" - which I suppose could be a view, table, named query... When I choose data source view I can only see the table that is already being used as a fact table in the measure group (and this is actually a named query and not a table). When I choose the data soure, eg. the underlying database, I get nothing.

|||

I found the answer myself.

I thought I had the same datatypes because I created my new named query from the original table that the first named query (the one being used in the measure group already) was based on. But it turned out that the first named query did not get the same datatypes i all columns as the underlying table.

In BOL it states that the tables (or named queries) used in the same measure group must be sufficiently similar - I would call it exactly the same :-)