简体   繁体   中英

Updating Measure in SSAS Cube

Is there a way to create a new measure in an SSAS (SQL Server Analysis Server) cube, other than modifying and re-running the entire CREATE XMLA cube script?

Tried the following stand-alone MDX queries:

Query #1

CREATE MEMBER CURRENTCUBE.Measures.[TestMeasure] AS 
NULL;

Result:

Executing the query ...
No cube specified. A cube must be specified for this command to work.
Execution complete

Query #2

CREATE MEMBER [CubeName].Measures.[TestMeasure] AS 
NULL;

Result:

Executing the query ...
Execution complete

Note: Query #2 executes but measure does not appear in "CubeName" cube.

CREATE MEMBER is scoped, so those members don't persist outside of your session/query.

In order to create a new permanent calculated member on your CUBE you need to use an ALTER XMLA script, not a CREATE XMLA script.

One example, shamelessly pilfered from the web:

<Alter AllowCreate="true" ObjectExpansion="ExpandFull" xmlns="http://schemas.microsoft.com/analysisservices/2003/engine">
  <Object>
    <DatabaseID>CVCC</DatabaseID>
    <CubeID>CVCC</CubeID>
    <MdxScriptID>MDXScript</MdxScriptID>
  </Object>
  <ObjectDefinition>
    <MdxScript>
      <ID>MDXScript</ID> 
      <Name>MDXScript</Name>
      <Commands>
        <Command>
          <Text> <!–if you want to figure out what to paste below build the calculation in visual studio then look at the ‘script view’–>
            CALCULATE;
            CREATE MEMBER CURRENTCUBE.[MEASURES].[TestMeasure]
            AS **Your calc goes here**;
          </Text>
        </Command>
      </Commands>
    </MdxScript>
  </ObjectDefinition>
</Alter>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM