Lesson 3-3 - Modifying the Product Dimension
Applies to: SQL Server Analysis Services Azure Analysis Services Fabric/Power BI Premium
In the tasks in this topic, you use a named calculation to provide more descriptive names for the product lines, define a hierarchy in the Product dimension, and specify the (All) member name for the hierarchy. You also group attributes into display folders.
Adding a Named Calculation
You can add a named calculation to a table in a data source view. In the following task, you create a named calculation that displays the full product line name.
To add a named calculation
To open the Adventure Works DW 2019 data source view, double-click Adventure Works DW 2019 in the Data Source Views folder in Solution Explorer.
In the bottom of the diagram pane, right-click the Product table header, and then click New Named Calculation.
In the Create Named Calculation dialog box, type ProductLineName in the Column name box.
In the Expression box, type or copy and paste the following CASE statement:
CASE ProductLine WHEN 'M' THEN 'Mountain' WHEN 'R' THEN 'Road' WHEN 'S' THEN 'Accessory' WHEN 'T' THEN 'Touring' ELSE 'Components' END
This CASE statement creates user-friendly names for each product line in the cube.
Click OK to create the ProductLineName named calculation. You might need to wait.
On the File menu, click Save All.
Modifying the NameColumn Property of an Attribute
To modify the NameColumn property value of an attribute
Switch to Dimension Designer for the Product dimension. To do this, double-click the Product dimension in the Dimensions node of Solution Explorer.
In the Attributes pane of the Dimension Structure tab, select Product Line.
In the Properties window on the right side of the screen, click the NameColumn property field at the bottom of the window, and then click the browse (...) button to open the Name Column dialog box. (You might need to click the Properties tab on the right side of the screen to open the Properties window.
Select ProductLineName at the bottom of the Source column list, and then click OK.
The NameColumn field now contains the text, Product.ProductLineName (WChar). The members of the Product Line attribute hierarchy now display the full name of the product line instead of an abbreviated product line name.
In the Attributes pane of the Dimension Structure tab, select Product Key.
In the Properties window, click the NameColumn property field, and then click the ellipsis browse (...) button to open the Name Column dialog box.
Select EnglishProductName in the Source column list, and then click OK.
The NameColumn field now contains the text, Product.EnglishProductName (WChar).
In the Properties window, scroll up, click the Name property field, and then type Product Name.
Creating a Hierarchy
To create a hierarchy
Drag the Product Line attribute from the Attributes pane into the Hierarchies pane.
Drag the Model Name attribute from the Attributes pane into the <new level> cell in the Hierarchies pane, underneath the Product Line level.
Drag the Product Name attribute from the Attributes pane into the <new level> cell in the Hierarchies pane, underneath the Model Name level. (You renamed Product Key to Product Name in the previous section.)
In the Hierarchies pane of the Dimension Structure tab, right-click the title bar of the Hierarchy hierarchy, click Rename, and then type Product Model Lines.
The name of the hierarchy is now Product Model Lines.
On the File menu, click Save All.
Specifying Folder Names and All Member Names
To specify the folder and member names
In the Attributes pane, select the following attributes by holding down the CTRL key while clicking each of them:
Class
Color
Days To Manufacture
Reorder Point
Safety Stock Level
Size
Size Range
Style
Weight
In the AttributeHierarchyDisplayFolder property field in the Properties window, type Stocking.
You have now grouped these attributes into a single display folder.
In the Attributes pane, select the following attributes:
Dealer Price
List Price
Standard Cost
In the AttributeHierarchyDisplayFolder property cell in the Properties window, type Financial.
You have now grouped these attributes into a second display folder.
In the Attributes pane, select the following attributes:
End Date
Start Date
Status
In the AttributeHierarchyDisplayFolder property cell in the Properties window, type History.
You have now grouped these attributes into a third display folder.
Select the Product Model Lines hierarchy in the Hierarchies pane, and then change the AllMemberName property in the Properties window to All Products.
Click an open area of the Hierarchies pane, and then change the AttributeAllMemberName property at the top of the Properties window to All Products.
Clicking an open area lets you modify properties of the Product dimension itself. You could also click Product at the top of the attributes list in the Attributes pane.
On the File menu, click Save All.
Defining Attribute Relationships
If the underlying data supports it, you should define attribute relationships between attributes. Defining attribute relationships speeds up dimension, partition, and query processing. For more information, see Define Attribute Relationships and Attribute Relationships.
To define attribute relationships
In the Dimension Designer for the Product dimension, click the Attribute Relationships tab.
In the diagram, right-click the Model Name attribute, and then click New Attribute Relationship.
In the Create Attribute Relationship dialog box, the Source Attribute is Model Name. Set the Related Attribute to Product Line.
In the Relationship type list, leave the relationship type set to Flexible because relationships between the members might change over time. For example, a product model might eventually be moved to a different product line.
Click OK.
On the File menu, click Save All.
Reviewing Product Dimension Changes
To review the Product dimension changes
On the Build menu of SQL Server Data Tools, click Deploy Analysis Services Tutorial.
After you have received the Deployment Completed Successfully message, click the Browser tab of Dimension Designer for the Product dimension, and then click the Reconnect button on the toolbar of the designer.
Verify that Product Model Lines is selected in the Hierarchy list, and then expand All Products.
Notice that the name of the All member appears as All Products. This is because you changed the AllMemberName property for the hierarchy to All Products earlier in the lesson. Also, the members of the Product Line level now have user-friendly names, instead of single-letter abbreviations.
Next Task in Lesson
See Also
Define Named Calculations in a Data Source View (Analysis Services)
Create User-Defined Hierarchies
Configure the (All) Level for Attribute Hierarchies