Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MDX YTD calculated measure

Tags:

sql

ssas

mdx

I'm still new to MDX and I'm trying to get some basic functions to work in my SSAS cube. Can you guys point out what I'm doing wrong here? I've added a calculated measure to my cube with the following code:

CREATE MEMBER CURRENTCUBE.[Measures].[Amount YTD]
AS
  AGGREGATE(
    YTD([OrderDate].[Calendar].CurrentMember)
   ,[Measures].[Amount]),
VISIBLE = 1, ASSOCIATED_MEASURE_GROUP = 'MyMeasureGroup';

After that I'm trying to get some data going...

SELECT 
NON EMPTY
{
  [Measures].[Amount]
, [Measures].[Amount YTD]
} ON COLUMNS,
NON EMPTY
{
  [OrderDate].[Month].ALLMEMBERS *
  [Product].[Product Group].ALLMEMBERS 
} ON ROWS
FROM (SELECT ([OrderDate].[Year].&[2014-01-01T00:00:00]:
              [OrderDate].[Year].&[2015-01-01T00:00:00]) ON COLUMNS
FROM [SalesOrderIntake])

This is the output I'm getting:

Query result

I'm not seeing any errors in my Output messages, which makes it difficult for me to figure out what is acting up. Hoping you guys can help me out on this one.

FYI: the actual select is just for testing purposes. I just want to get that YTD running. I've tried several things and it always comes out empty, so I was hoping to get some actual errors if I would query it directly in SSMS instead of using a BI tool. Also, the OrderDate dimension is a generated Time dimension which was provided to me by VS.

like image 385
Jens Avatar asked Jun 09 '16 12:06

Jens


People also ask

What is MDX calculated measure?

An MDX-calculated measure is created in the facts object of the cube model. An MDX-calculated member , however, is created in the dimension hierarchy of the cube model, at the global level. With Cubing Services, you can use MDX functions to build powerful analytics within the cube model.

What is YTD function?

The YTD function returns a set that contains a particular member of the Time hierarchy and all preceding members that are of the same level and are for the same year. The YTD function is equivalent to the PeriodsToDate function with a level of Time. Year specified.


1 Answers

In your query you're using what looks like an attribute hierarchy:

[OrderDate].[Month].ALLMEMBERS

Whereas the measure uses the user hierarchy:

[OrderDate].[Calendar]

If you use Calendar in your script does it work ok?

like image 104
whytheq Avatar answered Sep 23 '22 02:09

whytheq