The scope of the named sets and calculated members specified in the previous section is just the MDX statement in which they appear. Consequently, their lifetime is also limited to the life of the query execution.
It is frequently useful to have named sets and calculated members available for the life of a session, and visible to all queries in that session. When used with the UI-related set functions, named sets provide a powerful mechanism to create queries that not only preserve the state, but also provide an efficient method to process UI operations. For more information on how to do this, see “Preserving State During UI Operations” in this section.
To create a named set or a calculated member with longer scope and lifetime, use the following syntax:
create_formula_statement:= CREATE [scope] formula_specification
The syntax for formula_specification is exactly the same as the syntax used in creating named sets and calculated members. For information on syntax, see “Named Sets and Calculated Members” in this chapter. The create formula statement creates a named set or a named member.
The scope and lifetime of this created entity depends on the value of scope. There are two possible values of scope:
As an example, the MDX statement below creates the same dataset that is specified in “Cube and Dataset Example”:
CREATE SalesCube.ColumnsAxisSet AS CROSSJOIN({Venkatrao, Netz},
{USA_North.CHILDREN, USA_South, Japan})
CREATE SalesCube.RowsAxisSet AS {Qtr1.CHILDREN, Qtr2, Qtr3,
Qtr4.CHILDREN}
SELECT ColumnsAxisSet ON COLUMNS, RowsAxisSet ON ROWS
FROM SalesCube
WHERE (Sales, [1991], Products.All)
The following rules determine the semantics of named sets and members that are created by using create_formula_statement: