MDX Utility Belt of Calculations Part 1

, 2009-12-01

Developing MDX calculations is one of the most confusing and time consuming pieces of building an Analysis Services cube.  That is why I have accumulated what I like to call a Utility Belt of calculation that I can pull out at any moment to solve a problem.  I consider this a Utility Belt because on just about every Analysis Services project that I have worked on these calculations have come in handy and I hope they will be helpful for you.

When building calculations you may find the templates that are available in Business Intelligence Development Studio (BIDS) as a helpful starting point.  Unfortunately, I have found even using these templates can make calculations more confusing than they really need to be.

In this blog series I will give you the business problem, solution, and then calculation that satisfies the business problem. 

Problem

You need to return sales for one year prior (Ex. one year ago, four quarters ago, twelve months ago).

Solution

Use the ParrallelPeriod time series function to look back a set number of values back in a date hierarchy and return the sales at that point.

Calculations

Looking back one year at the Year level

(ParallelPeriod([Date].[Date Hierarchy].[Year],
1,
[Date].[Date Hierarchy].CurrentMember),
[Measures].[Sales Amount])

---------------------------------------------------------------

Looking back four quarters at the Quarter level

(ParallelPeriod([Invoice Date].[Date Hierarchy].[Quarter],
4,
[Invoice Date].[Date Hierarchy].CurrentMember),
[Measures].[Sales Amount])

---------------------------------------------------------------

Looking back twelve months at the Month level

(ParallelPeriod([Invoice Date].[Date Hierarchy].[Month],
12,
[Invoice Date].[Date Hierarchy].CurrentMember),
[Measures].[Sales Amount])

You can find me regularly blogging at http://www.bidn.com/blogs/DevinKnight

Rate

Share

Share

Rate

Related content

Database Mirroring FAQ: Can a 2008 SQL instance be used as the witness for a 2005 database mirroring setup?

Question: Can a 2008 SQL instance be used as the witness for a 2005 database mirroring setup? This question was sent to me via email. My reply follows. Can a 2008 SQL instance be used as the witness for a 2005 database mirroring setup? Databases to be mirrored are currently running on 2005 SQL instances but will be upgraded to 2008 SQL in the near future.

2009-02-23

1,567 reads

Networking - Part 4

You may want to read Part 1 , Part 2 , and Part 3 before continuing. This time around I'd like to talk about social networking. We'll start with social networking. Facebook, MySpace, and Twitter are all good examples of using technology to let...

2009-02-17

1,530 reads

Speaking at Community Events - More Thoughts

Last week I posted Speaking at Community Events - Time to Raise the Bar?, a first cut at talking about to what degree we should require experience for speakers at events like SQLSaturday as well as when it might be appropriate to add additional focus/limitations on the presentations that are accepted. I've got a few more thoughts on the topic this week, and I look forward to your comments.

2009-02-13

360 reads