MDX Utility Belt of Calculations Part 3

This is part three in a series of blog posts that will help you build an arsenal of MDX calculations that you can have ready at the drop of a dime.  The first two posts of this blog series use the ParrallelPeriod and PrevMember functions to return data at different levels.

All of these blog posts are formatted to give you the business problem, a general solution and then the calculation needed to finish the job.  The problem this time will use part of the solution we used from the second blog post.

Problem

You need to show the difference in sales of a date and that date’s previous member.  (Ex.  Show the sales difference between June and July.  Could likely be a negative number if there are fewer sales in July.)

Solution

You can return the sales for the CurrentMember and subtract it from the value of previous member using PrevMember.

Calculations

The sales for a year minus the sales of the previous year

([Date].[Year].CurrentMember,[Measures].[Sales Amount])-
([Date].[Year].PrevMember,[Measures].[Sales Amount])

—————————————————————

The sales for a quarter minus the sales of the previous quarter

([Date].[Quarter].CurrentMember,[Measures].[Sales Amount])-
([Date].[Quarter].PrevMember,[Measures].[Sales Amount])

—————————————————————

The sales for a month minus the sales of the previous month

([Date].[Month].CurrentMember,[Measures].[Sales Amount])-
([Date].[Month].PrevMember,[Measures].[Sales Amount])

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s