August 2001 MDX Puzzle Solution Revealed
The August 2001 MDX Puzzle challenged you to write an MDX query that returns a ranked set of the top 10 first-level subdirectories based on disk usage. Here's the solution.
July 30, 2001
In "Analyze Disk Utilization," August 2001, I introduced an analysis application that lets you explore the contents of your hard disk. The August MDX Puzzle, which was related to this application, challenged you to write an MDX query that returns a ranked set of the top 10 first-level subdirectories based on disk usage. You could also write an analogous query on the FoodMart HR cube that returns a ranked set of the top 10 first-level managers, based on number of employees.
Listing A shows the query for the DiskData cube. Listing B shows the query for the HR cube. Both queries use a special option of the Descendants() function, called Leaves, which returns all of an unbalanced hierarchy’s leaves. After you have all the leaves, you can determine the first-level parents by using a Generate() function that returns the list of unique parents of the leaves. The next step is to eliminate the parents that have grandchildren, because elements with grandchildren aren’t technically first-level parents. Last, you use the TopCount() function to return a ranked set of the top 10 first-level parents.
About the Author
You May Also Like