http://www.sqlservercentral.com/blogs/sqldownsouth/2010/08/27/mdx-puzzle-_2300_6-_2D00_-solution/

Printed 2014/04/20 01:46PM

MDX Puzzle #6 - Solution

By Patrick LeBlanc, 2010/08/27

Puzzle #6 should not have presented too much of a challenge, it's intentions were to introduction you to the ORDER function that is available in MDX.  Ok, so this is what I started with:

image

 

 

This is a very simple statement that satisfies most of the puzzle requirements.  The only one that is does not satisfy is the ordering of the results.  To do this I used the ORDER function.  The function accepts two arguments.  The first is a valid expression that returns a set.  In this example it is the set of Product Subcategories.  The next argument is the numeric or string expression, which will be used to determine the order.  Finally, you must include the direction that your want to order by, DESC or ASC.  There are a couple of more, but I am saving them for a later puzzle. 

Modifying the above query to include the ORDER function yields the result to this puzzle.  See the following:

image

 

Stay tuned for Puzzle #7, I promise it will be a little more challenging.

Talk to you soon,

Patrick LeBlanc, SQL Server MVP, MCTS

Founder www.TSQLScripts.com and www.SQLLunch.com.

Visit www.BIDN.com, Bring Business Intelligence to your company.


Copyright © 2002-2014 Simple Talk Publishing. All Rights Reserved. Privacy Policy. Terms of Use. Report Abuse.