MDX Usage Examples |
The data that is used in these examples is from a company that sells electronics and outdoor and sporting goods equipment.
Example 1 |
This example creates the session-level calculated member called avg_price in the sales cube on the Measures dimension. This calculated measure shows the average price:
create session member [sales].[measures].[avg_price] as '[Measures].[total] / [Measures].[qty]'
Nothing is returned when you create a session-level calculated member.
Example 2 |
This example uses the session-level calculated member called "avg_price." It shows the quantity, total, and average price of goods sold from 1998 through 2000.
SELECT {[measures].[qty], [measures].[total], [measures].[avg_price]} ON COLUMNS, {[time].[all time].children} ON ROWS FROM sales
Here is the resulting output:
Year | Qty | Total | Average Price |
---|---|---|---|
1998 | 440,852 | 10,782,352.94 | 24.4579880322648 |
1999 | 539,433 | 14,080,419.58 | 26.1022584454418 |
2000 | 32,267 | 859,108.83 | 26.6249986053863 |
Example 3 |
This example uses the session-level calculated member called "avg_price." It shows the quantity, total, and average price of goods sold in different customer regions.
SELECT {[measures].[qty], [measures].[total], [measures].[avg_price]} ON COLUMNS, {[customer].[all customer].children} ON ROWS FROM sales
Here is the resulting output:
Example 4 |
This example uses the session-level calculated member called "avg_price." It shows the quantity, total, and average price of goods sold in the different product groups.
SELECT {[measures].[qty], [measures].[total], [measures].[avg_price]} On COLUMNS, {[product].[all product].children} ON ROWS FROM sales
Here is the resulting output:
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.