Building a Basic SSAS Cube

Last time we started looking at how to use SSAS to load fact and dimension tables from the Contoso Retail Data Warehouse example.  We saw that even after only defining our data source and data views that we could generate simple pivot tables from the raw data.  However, those pivot tables were limited to data from a single source table or view.  Sure, you could denormalize your data further so that a single fact table included all the measures and dimensions you needed to create a pivot table, but there are bigger problems such as how to give end users access to the pivot tables and pivot charts without also giving them access to SSAS.  However, a discussion of user access will come later in this series.  First, let’s see how to create a proper cube in SSAS.

Let’s pick up the discussion from the point where we have defined the data source view.

We could immediately jump into creating a New Cube by right clicking on Cube and then selecting New Cube from the popup menu.  This action invokes the cube wizard that allows us to select which tables to use as fact tables and which tables to use as dimension tables.  While the wizard allows us to select the measures to include in the cube from the fact table, no such option exists for selecting the attributes from the dimension tables.  Rather, the wizard only selects the key field from the dimension table.  That does not provide any more information than the corresponding foreign key value in the fact table.  While you can go back and fix this, I generally ignore this wizard and build my dimensions manually.

Therefore, I would begin by right clicking on Dimensions in the Solution Explorer and selecting New Dimension.  Skipping the first screen of the Dimension Wizard, I would select the option to create the dimension from an existing table.  Note some of the other options available in this wizard related to time dimensions and non-time tables built with other dimensions.  I promise to explore these topics in a future blog.

After clicking Next, the Specify Source Information screen allows me to select the Data Source View.  Since I only have one view defined in this project, the default view is correct.  However, for the Main Table, I want to use the dropdown to select the first dimension table.  Note that I can even use fact tables as dimension tables.  A fact table used like this is called a degenerate dimension.  For now, I will ignore the fact table and go immediate to my first dimension table.  Note that just because a view includes a dimension table, that does not mean the current cube must use it.  For example, I could build a simple cube here using only the Channel and Date dimensions.   However, I must build one dimension at a time, so let’s build the first dimension on DimChannel.

Note that in addition to selecting the table, the wizard automatically selects the key column, ChannelKey, and lets you select a Name Column.  For this table, the obvious choice for the name column is ChannelName.  We will see a little later how the Channel Name will automatically appear in our cube when we drag the Channel Key into one of the dimensions.

The next page of the wizard allows you to select other attributes of the dimension to include.  You can choose any attribute individually by checking the checkbox to the left of the attribute name.  You can also select all of the attributes in the table by checking the checkbox to the left of the header Attribute Name at the top of the list.


The final page of the wizard lets you name the dimension.  By default, the wizard parses the name of the table selected and automatically puts spaces before each capital letter after the first character in the table name to create a user friendly name as it assumes you are using Camel or Pascal case.

When you click Finish, you should see the new dimension definition in the Solution Explorer under Dimensions.  Similarly, I would create dimension for DimDate.  Notice before we move on to creating the cube using our manually defined dimensions that after each dimension is created, a three panel screen appears in the main portion of the screen with the headers: Attributes, Hierarchies, and Data Source View.

Here we can build an attribute hierarchy.  For example, we know that years contain quarters which contain months.  We can build a hierarchy that represents this relationship by first dragging Calendar Year Label to the center column.  Then drag Calendar Quarter Label to a position immediately beneath Calendar Year Label.  Finally, drag Calendar Month Label beneath the other two fields.  By right clicking on the header: Hierarchy, we can rename our custom hierarchy to anything we like such as: YearMonth.

Note that the tab, Dim Date.dim [Design], at the top of this screen section has an asterisk after the name.  This tells you that the changes you entered have not yet been saved.  You can either click the Save icon in your toolbar or you can right-click this tab and click Save Selected Items.

With our dimensions defined, right click on Cubes in Solution Explorer and select New Cube.  Skipping over the Welcome screen for the Cube Wizard, you can choose to build the cube using existing tables, build an empty cube, or generate tables in the data source.  Select Use Existing Tables and click Next.

On the next screen in the wizard, you need to select the Measure Group table.  In this example, the only measure group table is FactSales.


In the next screen, you can choose the measures to include in the cube.  By default, the wizard includes all the fields in the fact table as measures.  Often a fact table includes columns that you may not be interested in using as measures in the cube.  Therefore, you can deselect any of the measures that you do not think the users will need by deselecting the checkbox to the left of each measure name you want to remove.  Notice that the wizard automatically provides a new column that did not exist in the original fact table named: Fact Sales Count.  This measure contains a formula that displays a count of records when added to a cube.


The next screen in the wizard shows the names of the existing dimensions.  As mentioned before, you do not need to use every dimension defined for every cube.  In this case, only two dimensions appear because I only manually created those two and will use both in the definition of this cube.

The wizard also recognizes from the view definition that there are other tables for which potential dimensions have not been defined and offers to create new dimensions based on those tables as seen in the next figure.  In this case, I already deselected all of these additional dimensions to keep this example simple.

The final screen of the wizard shows the selection of measures in the fact table and the selected dimensions.  It suggests a name for the cube based on the name of the view used.  However, you can change the cube name.  If you use the same data source view to create multiple cubes, you must define unique cube names for each cube.

When you click Finish, the center working area shows panels that display the Measures, the Dimensions and a Data Source View.

Also a series of tabs appear across the top of this section.  For now, the only other tab we will examine is the Browser tab.  However, before we can click this tab, we need to build our cube.  To build the cube, click Build ContosoPivot (the name of our solution) in the dropdown menu from the Build option in the main menu.  For a cube of this size, the build should complete in only a second or two.  You will see the text: Build Succeeded in the left side of the Status Bar when the build completes.  If an error occurs during the build, the Error List window will open and itemize the errors found.  Some errors might just be warnings and the cube will still build.  However, you should always review warnings, not just errors.

After the build of the cube succeeds, you still need to deploy the cube before you can view it.  Again you can go to Build menu option but this time select Deploy ContosoPivot.  Again because of the small size of this cube, the deploy step should complete relatively quick.  However, for larger cubes with many dimensions, this process can take from a few seconds to a few minutes.  If the deploy is successful, you should see a panel in the lower right with the tab name Deployment Progress which displays a green Deployment Completed Successfully message or a red Deployment Failed message.  Again the Error List will help you debug any errors that occur during the deploy process.

Now when you click on the browser tab, you will see an empty view of the cube.  From the list of groups on the right side, you can add facts to the body of the cube and then define row and column dimensions from the data used when defining the cube.  In the final figure for this week, you see a cube that displays Sales Amount from the fact table as a function of the channel and date dimensions.  Note that I was able to drag Channel Key to define the rows, but instead of displaying an integer key value, the Channel Name appeared because of associating the Channel Name field with the Channel ID field when I defined the dimension.  Similarly, I use the YearMonth hierarchy that I defined in the date dimension to define my columns.  Note in the figure that I opened the levels so you can see that the levels: Year -> Quarter -> Month were build correctly for me.

Next week, I talk a little more about some of the formatting features for the cube and the use of filters.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s