Wednesday, March 7, 2012

can calculation be defined in SQL Server Management Studio?

hi!can somenboby hlep me,i want to know that can calculations be defined in SQL Server Management Studio?And how to do it?Thank you very much!

Calculations are added to a new or existing cube using "Business Intelligence Development Studion" (BIDS). You could generate the script for a cube and then add the calculation by hand, but it is much easier to do using BIDS. If you simply want to create and test a calculation using SQL Server Management Studio you can add a query scoped member using a WITH clause in the MDX editor. Here is a simple example that can be run against Adventure Works:

WITH MEMBER Measures.[Internet Sales x 2]

AS

[Measures].[Internet Sales Amount] * 2

SELECT

{[Measures].[Internet Sales Amount],

[Measures].[Internet Sales x 2] } ON COLUMNS

FROM

[Adventure Works]

HTH,

Steve

|||thank you ,steve.this is a usefulness way.if i just want to creat calculation using SQL Server Management Studio ,like create calculation using BIDS that the calculation can show in measures,does it achieve?|||

If I understand your question correctly the answer is no. The WITH MEMBER calculation is only good for the life of the query. If you want to add a measure to a cube that can be used by others accessing the cube then I would use BIDS.

Steve

|||except using BIDS,does it exist another way to resolve the problem,for example,some script?|||

If your only alternative is SQL Server Management Studio, you can add a calculated member by running an ALTER cube script. In SSMS connect to the AS server where your cube is located. Expand the database and cube folders until you find the cube you want to add a calculated member to. Right click on the cube and then choose:

Script Cube as -> ALTER to -> New Query Editor Window

Then do a search on the script for MdxScripts. You should now see the calculation script for the cube. Edit the script to add in your CREATE MEMBER statement and then run the script. As long as your MDX is error free, you should now be able to see your new calculated member when you access the cube.

HTH,

Steve

No comments:

Post a Comment