Database Journal
MS SQL Oracle DB2 Access MySQL PostgreSQL Sybase PHP SQL Etc SQL Scripts & Samples Links Database Forum

» Database Journal Home
» Database Articles
» Database Tutorials
MS SQL
Oracle
DB2
MS Access
MySQL
» RESOURCES
Database Tools
SQL Scripts & Samples
Links
» Database Forum
» Sitemap
Free Newsletters:
DatabaseDaily  
News Via RSS Feed


follow us on Twitter
Database Journal |DBA Support |SQLCourse |SQLCourse2
 

Featured Database Articles

MS SQL

Posted Aug 16, 2004

Introduction to MSSQL Server 2000 Analysis Services: Derived Measures vs. Calculated Measures - Page 6

By William Pearson

The syntax we have typed into the Source Column property mirrors the logic behind the syntax for the calculated member, which we explained in Table 1 above. The syntax in the Source Column property must be appropriate to the underlying database upon which it is intended to operate (in this case, the MS Access Foodmart database). As might be expected, the syntax to obtain a given result will differ between RDBMS'.

9.  Click the Advanced tab of the Properties pane.

10.  Select the following Display Format:

#,#.00

The Properties pane, Advanced tab appears as depicted in Illustration 20.


Illustration 20: Properties Pane - Advanced Tab, with our Display Format Selection

11.  Select Tools --> Process Cube once again, to reprocess the cube.

12.  Click Yes when prompted to save the cube, as we did earlier.

13.  Click No upon the prompted offer to design storage, and complete the rest of the steps in reprocessing the cube as we did earlier.

Processing begins, as it did earlier, and concludes with the green Processing completed successfully message, as before.

14.  Click Close to dismiss the viewer.

Cube data is again retrieved (click the Data tab, as required), and we are once more able to see the values for all measures, including the new derived measure, DM_Cost with Promo Alloc. We will drag the MSAS Admin's calculated measure, CM_Cost with Promo Alloc, to the top of the members listed in the Calculated Members folder, and thus be able to see it side by side in the Data view with the new derived measure, DM_Cost with Promo Alloc, for comparison purposes, before we eliminate the calculated measure.

15.  Within the Calculated Members folder of the tree pane, click the calculated measure CM_Cost with Promo Alloc.

16.  Drag the calculated measure to the top of the tree within the Calculated Members folder.

The calculated measure CM_Cost with Promo Alloc appears atop the tree. There it is "next in line" to the measure at the bottom of the tree in the Measures folder, our new derived measure, DM_Cost with Promo Alloc, as shown in Illustration 21.


Illustration 21: Aligning the Derived and Calculated Measures for Comparison in the Data View

17.  In the Data view, reposition the row axes, if necessary, so that the row headings display the Store Type / Promotion Name combination we set up earlier.

18.  Scroll over in the Data view until the columns headed CM_Cost with Promo Alloc and DM_Cost with Promo Alloc appear, as depicted in Illustration 22.


Illustration 22: Aligning the Derived and Calculated Measures for Comparison in the Data View

Side by side, we can see that the derived measure appears to return the same value as the calculated measure, with two exceptions - both of which add to the desirability of the derived measure as a solution. First, there is a difference in the "All Promotions" value, atop the Promotion Name rows. This is due to the correct exclusion, by the derived measure, of the "No Promotion" promotion row from the fifteen percent uplift calculation. (Test the math, if desired).

The other difference is the placement of the zeros in the new derived measure column, which is a result of our "outer IIF" statement. The statement prevents an error that would be indicated were it not in place. (We could replace or hide the zero easily enough, but for this session, let's leave it in place.)

19.  Drill further or otherwise experiment with the derived measure to get a comfort level with its accuracy, if desired.

We will now eliminate the calculated measure, CM_Cost with Promo Alloc, as the derived measure has been verified to meet the business requirements (enhanced query performance and accurate results) specified by the information consumers.

20.  Right-click the CM_Cost with Promo Alloc calculated measure, within the tree pane of the Calculated Members folder.

21.  Select Delete from the context menu that appears, as shown in Illustration 23.


Illustration 23: Deleting the Calculated Measure ...

The calculated measure disappears from the tree pane.

22.  Select File --> Exit to leave the Cube Editor, when ready (saving the cube, if prompted).

We are returned to the Analysis Manager console.

23.  Select File --> Exit to leave Analysis Services, when desired.

Conclusion

In this article, we explored the use of derived measures to enhance cube query response time. Discussing the drawbacks in using calculated members in cases where a derived measure might be substituted, we considered the benefits and disadvantages that might accrue using derived measures. We then began a practice exercise, the preparation for which involved the creation of a simple calculated measure, which we used to serve as the "existing," less-than-optimal solution that had already been provided to our hypothetical group of information consumers. The calculated measure served as a basis for comparison with our more optimal solution, the derived measure.

We described the requirement of the information consumers to enhance query response time, and, in answer to their need, we determined that a derived measure might best be substituted for the existing calculated measure. We then implemented our solution through creation of a derived measure to replace the existing calculated measure. Finally we discussed the results obtained, verifying the values provided by our solution against those produced by the calculated measure, before eliminating the latter from the cube.

» See All Articles by Columnist William E. Pearson, III

Discuss this article in the MSSQL Server 2000 Analysis Services and MDX Topics Forum.



MS SQL Archives

Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 




Latest Forum Threads
MS SQL Forum
Topic By Replies Updated
SQL 2005: SSIS: Error using SQL Server credentials poverty 3 August 17th, 07:43 AM
Need help changing table contents nkawtg 1 August 17th, 03:02 AM
SQL Server Memory confifuration bhosalenarayan 2 August 14th, 05:33 AM
SQL Server Primary Key and a Unique Key katty.jonh 2 July 25th, 10:36 AM