Skip to main content
Previous section   Next section

CREATE SET Statement

Creates a named set that can be used within the current session.

Syntax and Details

CREATE SESSION SET cube_name.set_name AS 'set_expression'
  • cube_name is the name of the cube to which you are adding this set.
  • set_name is an unquoted string that names the set. Later you can use this set name in the place of a set expression in any MDX query within the same session.
When you use the MDX shell, a session is started; the session ends when you exit the shell. During this session, if you use the CREATE SET statement, the member that you create is available until the session ends or until you use the DROP SET statement.

Example

First, in the MDX shell, we define a new named set in the
Patients
cube:
>>CREATE SESSION SET patients.testset AS 'birthd.decade.MEMBERS'
 
---------------------------------------------------------------------------
Elapsed time:       .014451s
Then we use the named set in a query:
>>SELECT MEASURES.[%COUNT] ON 0, testset ON 1 FROM patients
                             Patient Count
 1 1910s                                 71
 2 1920s                                223
 3 1930s                                572
 4 1940s                                683
 5 1950s                              1,030
 6 1960s                              1,500
 7 1970s                              1,520
 8 1980s                              1,400
 9 1990s                              1,413
10 2000s                              1,433
11 2010s                                155
---------------------------------------------------------------------------
Elapsed time:       .018745s

See Also

Previous section   Next section