SSAS:程序化的&永久创建计算成员

本文关键字:创建 计算 成员 程序化 SSAS | 更新日期: 2023-09-27 18:02:50

我正在尝试使用c#代码中的MDX ADOMD命令永久创建计算维度成员。下面的MDX脚本创建了成员,但它只对当前会话可用。

CREATE MEMBER [Cube].[Dimension].[Hierarchy].[My Member Name] as 
    Aggregate({
        [Dimension].[Hierarchy].[Level].&[1], [Dimension].[Hierarchy].[Level].&[2], ...
    })   

如何永久创建它?

SSAS:程序化的&永久创建计算成员

从未尝试过,但我发现一些AMO代码似乎可以做到这一点,它正在从立方体加载当前的MDX计算脚本,添加到其中,然后将其发布回来。

Dim objServer As Server
Dim objDatabase As Database
Dim strDataBaseID As String
Dim objCube As Cube
Dim objMdxScript As MdxScript
Dim objCommand As Command
Dim strCommand As String
objServer = New Server
objServer.Connect(“localhost”)
objDatabase = objServer.Databases(“Adventure Works DW 2008″)
strDataBaseID = objDatabase.ID
If objDatabase.Cubes.Count > 0 Then
objCube = objDatabase.Cubes(“Adventure Works”)
If objCube.MdxScripts.Count > 0 Then
objMdxScript = objCube.MdxScripts(“MdxScript”)
”objMdxScript = objCube.MdxScripts(0) 
Else
objCube.MdxScripts.Add(“MdxScript”, “MdxScript”)
objMdxScript = objCube.MdxScripts(“MdxScript”)
End If
objCommand = New Command
strCommand = “CREATE MEMBER CURRENTCUBE.[Measures].[Multipy Measures By 20]“
strCommand = strCommand & ” AS [Measures].[Internet Sales Amount] * 20, “
strCommand = strCommand & ” VISIBLE = 1 ; “
objCommand.Text = strCommand
objMdxScript.Commands.Add(objCommand)
objMdxScript.Update()
objCube.Update()
End If
objServer.Disconnect()

发现于http://www.win8s.com/sql-server/sql-server-analysis-services/2011/programically-changing-calculated-members.html

我在其他地方使用AMO,但没有像这样使用它,所以请报告结果:)