Additional MDX Statements
This documentation is for Kyvos 2026.6.x. To view documentation for other Kyvos versions, click here. |
|---|
CREATE SESSION MEMBER
Description: Creates a calculated member scoped to the current session. Unlike WITH MEMBER (query-scoped), session members persist across multiple queries until the session ends or the member is explicitly dropped.
Syntax: CREATE SESSION MEMBER Parent.MemberName AS Expression [, Property_Name = Property_Value, ...]
Input: A dimension parent, member name, MDX expression, optional properties
Output: A persistent session-level calculated member
Business Use Case: Define a standard Gross Profit measure once at session start and reuse in all subsequent queries.
-- Define once for the session
CREATE SESSION MEMBER [Measures].[Session Profit] AS [Measures].[Internet Sales Amount] - [Measures].[Total Product Cost]
-- Use in subsequent queries without re-defining SELECT
{[Measures].[Internet Sales Amount], [Measures].[Session Profit]} ON COLUMNS,
[Product].[Product Categories].[Category].Members ON ROWS
FROM [Adventure Works]Session member with formatting:
CREATE SESSION MEMBER [Measures].[Gross Margin %] AS
([Measures].[Internet Sales Amount] - [Measures].[Total Product Cost])
/ [Measures].[Internet Sales Amount], FORMAT_STRING = "Percent"
SELECT
[Measures].[Gross Margin %] ON COLUMNS, [Product].[Product Categories].[Category].Members ON ROWS
FROM [Adventure Works]
CREATE SESSION SET
Description: Creates a named set scoped to the current session. The set is re-evaluated each time it is referenced (dynamic).
Syntax: CREATE SESSION SET [SetName] AS Set_Expression
Business Use Case: Define a "Core Products" set once that is automatically re-evaluated based on current filters.
-- Define session set
CREATE SESSION SET [TopProducts] AS
TopCount(
[Product].[Product].[Product].Members, 10,
[Measures].[Internet Sales Amount])
-- Use in multiple subsequent queries SELECT
[Measures].[Internet Sales Amount] ON COLUMNS, [TopProducts] ON ROWS
FROM [Adventure Works]CREATE SESSION STATIC SET
Description: Creates a session set that is evaluated once at creation time. Members are fixed regardless of subsequent context changes.
Syntax: CREATE SESSION STATIC SET [SetName] AS Set_Expression
Business Use Case: Capture the top-5 products at report time; the same 5 products appear regardless of how the report is filtered afterward.
CREATE SESSION STATIC SET [StaticTopProducts] AS TopCount(
[Product].[Product].[Product].Members, 5,
[Measures].[Internet Sales Amount])
-- Later queries always use the same 5 products SELECT
[Measures].[Internet Sales Amount] ON COLUMNS,
[StaticTopProducts] ON ROWS FROM [Adventure Works]
WHERE [Date].[Calendar].[Calendar Year].[2012]