Actions in Multidimensional Modeling
Actions are objects within a SQL Server Analysis Services (SSAS) cube that enable users to perform tasks on cube data, such as navigating to related data, executing commands, or drilling down to detailed reports. They provide a powerful way to interact with and gain deeper insights from your multidimensional data.
Introduction to Actions
Actions are defined at the cube level and can be associated with various cube objects, including dimensions, hierarchies, levels, members, measures, and the cube itself. When a user interacts with a cube member that has an associated action, a menu or link appears, allowing them to trigger the action.
Types of Actions
SSAS supports several types of actions:
- Drill Through: Allows users to see the underlying transactional data that contributes to a specific measure or cell value.
- Drill Down: Navigates the user to a lower level in a dimension hierarchy.
- Report Actions: Opens a predefined report (e.g., an SSRS report) with context passed from the cube.
- URL Actions: Navigates the user to a specified URL, often passing cube context as parameters.
- Stored Procedure Actions: Executes a stored procedure on an external data source.
- Command Actions: Executes a command, such as opening another application or running a script.
Creating Actions
Actions can be created using SQL Server Data Tools (SSDT) or programmatically using AMO (Analysis Management Objects) or XMLA (XML for Analysis). In SSDT, you typically right-click on the cube object in Solution Explorer and select "New Action".
Action Properties
Each action has several key properties:
- Name: A unique identifier for the action.
- Target Objects: The cube objects to which the action is associated.
- Type: The type of action (e.g., Drill Through, URL).
- Expression: A Multidimensional Expressions (MDX) expression that defines the scope and behavior of the action. This is crucial for determining when and how the action is displayed.
- Target: For URL and Report actions, this specifies the target URL or report name.
- Parameters: For Report and Stored Procedure actions, this defines the parameters to be passed.
Understanding the Action Expression
The action expression is a powerful MDX statement that determines:
- When the action is visible: The expression should return a non-empty set of members for the action to be available.
- What context to pass: The expression can return specific members or values that are used as parameters for the action's target.
Filter, Crossjoin, and StrToVALUE to dynamically generate the desired context for your action expressions.
Action Execution
When a user selects an action, the client application:
- Evaluates the action's MDX expression to determine the context.
- If the action type is Drill Through, it queries the underlying data source for detailed records.
- If it's a URL or Report action, it constructs the URL or report call using the evaluated context.
- If it's a Stored Procedure action, it executes the stored procedure with the provided parameters.
Examples
Drill Through Action Example
An action that allows users to drill through to see sales transaction details for a selected product:
// Target Objects: Sales Measure Group
// Type: DrillThrough
// Expression: NON EMPTY { [Measures].[Sales Amount] } ON ROWS,
// [Product].[Category].[Category].MEMBERS ON COLUMNS
When a user clicks on a sales amount cell for a specific product, they will see the individual sales transactions contributing to that amount.
URL Action Example
An action that opens a web page displaying product information:
// Target Objects: Product Dimension
// Type: Url
// Expression: "[http://example.com/productinfo?id=" + Product.CurrentMember.Properties("ProductID").Value + "]"
Clicking on a product member will open a URL like http://example.com/productinfo?id=123.