Mondrian‎ > ‎

MDX : Calculate Sales Growth from Previous Period


MDX has a very useful function to refer to previous period of a time dimension, that function is PrevMember. With this function we can calculate growth based on current and previous period value.


We well based our sample on Foodmart's Sales cube to create a view of Unit Sales growth for each period.

Here are the steps:
  • Start your Mondrian server
  • Open to your Mondrian app in your browser.  For example my Mondrian app is located in http://localhost:8080/mondrian
  • Once the menu page appears, click on the JPivot pivot table link

  • Test Query uses Mondrian OLAP page will appear shortly
  • Click on MDX button to show mdx editor

  • Type this MDX query inside the editor. Notice the use of PrevMember function.

  • Click Apply button.
  • You now have a slice and dice table showing Unit Sales growth measure from previous period, try to drill down on Time dimension by clicking +/- link button.

  • Done