Home > Articles > Data > SQL Server

  • Print
  • + Share This
Like this article? We recommend

Creating a Local Cube from a Relational Source

Our second approach to creating a local cube will consist of a return to Microsoft Query. We also saw Microsoft Query appear in the creation of the database and connection phases of the PivotTable report setup in the earlier part of this lesson.

We use Microsoft Query to create a subset of a relational data source and then finish the cube-creation process using the OLAP Cube Wizard.

Start with a Relational Data Subset

Sometimes, we have neither a server-based cube nor an Analysis Server available, but we can access a relational data source. For example, we may become involved in the early phases of transitioning an enterprise to the use of local cubes for remote users, say a team of salespeople or managers who need analytical capabilities on their laptops. We may need to prototype an eventual solution by outfitting a representative test group with basic cubes in order to obtain useful feedback regarding the contemplated design for a server-based generation and distribution environment. After obtaining the specifics from the information consumers, we can more effectively place the final design in production and allow the server to generate the cubes in an automated fashion for field deployment.

The capability to design and create cubes directly from a relational data source provides an excellent opportunity to perform "proof-of-concept" exercises with a reality-based model that will prompt consumers to more clearly specify their requirements. Users who are unfamiliar with OLAP and its uses can see the model in action, and can relate it to their day-to-day needs and signal suggested improvements from the standpoint of both the overall cube structure (including the dimensions, measures, and other components that are critical to effective design) and the interface and usability considerations of a more mechanical nature.

Furthermore, local cubes offer the capability of "parallel testing" proposed model changes while a production cube build process takes place in an insulated manner, both as a troubleshooting and continuous-improvement process. For example, many clients with whom I have worked in the past have asked me to investigate issues with cube size and performance. The cube under consideration was often the Production model, so we were not afforded the luxury of simply taking it offline to modify and tune its build cycle. Using a "zero-based" approach to constructing a new cube (a rapid process using a local prototype) based upon the currently desired reporting output of the Production cube, many issues were subsequently resolved through a close investigation of what data in the cube was actually being used in the field; redundancies and abandoned elements often came to light through a rapid redesign that was based on current needs. Moreover, examination of the "layers" (which were gradually added onto the original cube structure as consumer needs became known) at which summarization was being attempted often led to the derivation of a creation cycle that was more finely attuned to the effective use of preprocessing and aggregation at the RDBMS level, where appropriate. In situations such as these, and in many others, the generation of a local cube from the relational source tables can be highly useful to the organization in a number of ways.

As discussed previously, we begin the direct-from-relational creation of a cube by first deriving a subset of the relational data. Preparation involves 1) setup of a data source for the relational database; then 2) creation of the query that specifies the selection criteria for the subset. A query tool is needed to precisely identify the parameters of that subset; once again, Microsoft Query provides a straightforward means of achieving the creation of this subset (or rowset, as it is called when using the SQL–based Microsoft Query tool). Microsoft Query allows us to perform joins between the dimension and fact tables, to create calculated columns, and to otherwise prepare a "virtual warehouse" on a miniature scale from which to build a cube. After we establish the rowset, we use the OLAP Cube Wizard to design the cube and its member objects (including measures, dimensions, hierarchical levels, and so forth).

Let's get started by defining the rowset upon which the cube will be based. We'll keep the structure fairly simple to allow us to focus on design and creation concepts as we proceed.

  1. Open a new Microsoft Excel worksheet.

  2. Select Data from the top menu.

  3. Select Get External Data from the dropdown menu.

  4. Click New Database Query from the flyout menu, as shown in Figure 21.

    Figure 21Figure 21 Initializing the rowset query.

Microsoft Query is initialized, and the Choose Data Source dialog box appears, as shown in Figure 22.

Figure 22Figure 22 Choose Data Source dialog box for Microsoft Query.

  1. On the Database tab of the dialog box (the default when the dialog box appears), choose Microsoft Access Database, as shown in Figure 22.

    Notice that the Query Wizard is enabled via the default setpoint on the dialog box—the checkbox—to assist in guiding us through the design process.

  2. Click OK.

    The Select Database dialog box appears, along with a Connecting to Data Source progress dialog box.

  3. Find and select the FoodMart 2000 Access database (FoodMart 2000.mdb), which is typically installed in the Samples folder of the Microsoft Analysis Services directory under Program Files on the drive upon which the Typical installation took place. (In my case, for example, the .mdb is located at D:\Program Files\Microsoft Analysis Services\Samples).

    The Select Database dialog box should resemble Figure 23.

    Figure 23Figure 23 Select Database dialog box.

  4. Click OK.

    The Query Wizard – Choose Columns dialog box appears, as shown in Figure 24.

    Figure 24Figure 24 Query Wizard – Choose Columns dialog box.

  5. Select the tables listed below from the Available Tables and Columns box on the left by double-clicking each (or by selecting each and clicking the > button) to move the respective columns to the right.

    • product
    • product class
    • region
    • sales_fact_1998
    • store
    • time_by_day

While we would probably expand each table and select the specific columns we needed for our cube in a real world scenario, we will select each of the tables in its entirety at this point, to make the process quicker for our lesson.

  1. Click Next.

    The Query Wizard – Filter Data dialog box appears, as shown in Figure 25.

    Figure 25Figure 25 Query Wizard – Filter Data dialog box.

We will simply click Next to skip this step, again noting the importance of filtering the data in a real-world scenario to keep cube size minimal when the relational data source is large.

  1. Click Next.

    The Query Wizard – Sort Order dialog box appears, as shown in Figure 26.

    Figure 26Figure 26 Query Wizard – Sort Order dialog box.

Again, we will pass on sorting the data; we will not be working with the end product in this lesson. This, too, would obviously be handled differently in the business environment.

  1. Click Next.

    The Query Wizard – Finish dialog box appears, as shown in Figure 27.

    Figure 27Figure 27 Query Wizard – Finish dialog box.

  2. Click Save Query, and name the query Tutorial-LocalCube, placing it in a convenient directory or accepting the default.

    The Save As dialog box resembles that shown in Figure 28.

    Figure 28Figure 28 Saving the underlying relational query.

  3. Click OK.

    The Query Wizard – Finish dialog box returns.

  4. Click the Create an OLAP Cube from this query radio button to select it (refer to Figure 27).

  5. Click Finish.

The OLAP Cube Wizard is launched, based on our selection in the Finish dialog box. It appears as shown in Figure 29, awaiting instructions about how we want it to create the cube for which we have created a source definition in Microsoft Query.

Figure 29Figure 29 The OLAP Cube Wizard welcome dialog box appears.

Finish the Job with the OLAP Cube Wizard

We now enter the cube design and creation phase of our second approach for creating a local cube. Our next steps focus upon the organization of the external data we have defined for extraction, and the manner in which we want it to summarize and to appear for analysis and reporting. Many reporting options exist, including PivotTable reports, PivotTable lists, PivotChart reports, and others. Many options also exist outside of the Microsoft Office suite because various third-party reporting tools can access the OLAP cube that we will generate.

The OLAP Cube Wizard allows us to begin with the output (a flat series of records) of the query we have designed in Microsoft Query, and to then apply a hierarchical organization to the fields. It also allows us to define the summary values we want to calculate for optimal reporting purposes. In addition to summarized values, our cube will contain descriptive facts surrounding those values. The values to be summarized, or measures as we know them from other OLAP scenarios, are called data fields within the context of the OLAP Cube Wizard. The descriptive facts, such as the date and location of a transaction, are organized into the hierarchical levels of detail that we know as dimensions.

The successful definition of the dimensions and their associated levels depends upon determining the kinds of categories that the information consumers employ (or want to be able to employ) when they analyze the data in reports and browsers. We can organize data fields and dimensions to endow organizational reports with high-level summaries (such as total costs worldwide, or at country or regional levels); while also enabling the presentation of lower-level details, filtered for a myriad of criteria (such as locations or areas of management responsibility where costs are particularly high, or, alternatively, well-controlled and minimal).

As discussed, the local cube design and creation process is easy, flexible and (best of all from the perspective of "proof of concept" and other prototyping exercises) fast. After we create and view reports based upon a new version of a local cube, we can return immediately to the OLAP Cube Wizard to make changes to adjust for consumer suggestions and comments regarding usability and performance, as well as to test ideas we formulate on an ad hoc basis. The local cube means isolation of the development process and uninterrupted operation of any production cubes that we have in place. It also means ultimate portability and convenience, both in the design phase and in a distributed production scenario.

Let's begin exploring the process involved in working with the wizard to create our local cube. The steps consist of the following:

  • Defining the data fields

  • Defining the dimensions and levels

  • Selecting the type of cube

  1. Click Next at the Welcome screen for the OLAP Cube Wizard.

    The OLAP Cube Wizard – Step 1 of 3 dialog box appears, as shown in Figure 30.

    Figure 30Figure 30 OLAP Cube Wizard – Step 1 of 3 dialog box.

The Step 1 of 3 dialog box is a great example of the way the wizard makes design straightforward and rapid—assuming that planning (based upon a solid understanding of the business requirements of the information consumers) has taken place before we embark upon cube design. We simply select from a list the data source fields that we wish to present, and how we wish to summarize each of those fields in an efficient and easy-to-use screen.

In this step, it is important that we decide which of our source data fields it makes sense to use as data fields. Data fields contain values (that is, they are measures) that we want to summarize, such as store costs for which information consumers have a need for totals. The wizard requires that we select at least one field to be a data field.

When the dialog box initially appears, the wizard has several boxes checked already. These are selected by the well-meaning (but not necessarily correct) wizard, based upon its conclusion that these fields appear to contain measure-like data. It "proposes" them, as a result, for selection in this step. It is critical to verify whether the wizard's proposals are correct and to make any changes to fit our business requirements. The fields that we leave unchecked in this step will comprise the set of available dimension fields in Step 2, from which we will select and organize those we need to design our dimension hierarchy structures.

  1. Fill out the Step 1 of 3 dialog box, ensuring that only the setpoints in Table 1 below exist (clearing any unwanted checkboxes).

    Table 1 Initial Measures List with Suggested New Names.

    Source Field

    Summarize By

    Data Field Name



    Store Sales



    Store Costs



    Store Unit Sales



    Total Sq. Ft.



    Grocery Sq. Ft.



    Frozen Sq. Ft.



    Meats Sq. Ft.

In the above setpoints, we made minor modifications to the field names because we might wish to fit terminology that exists in current reports, and so forth.

In addition to the "typical" measures for sales, costs, and unit sales, we selected the square footage information to illustrate the use of non-measure information to derive summaries. The square footage data could be stored at the member level as a property were we designing a cube in MSSQL Server 2000 Analysis Services—this approach would offer numerous advantages, not the least of which might be in areas of optimization.

The OLAP Cube Wizard – Step 1 of 3 dialog box now appears, with all relevant selections displayed, as shown in Figure 31.

Figure 31Figure 31 Step 1 of 3 dialog box with our selections.

  1. Click Next.

    The OLAP Cube Wizard – Step 2 of 3 dialog box appears.

In this step, we organize the descriptive data into dimensions, each of which can be used as a field in any reports we generate from our cube. The organization of the fields in levels of detail that we design at this stage should allow information consumers to select the level of detail to view, starting with high-level summaries, drilling to details, and zooming back to summaries as appropriate to meet their reporting needs.

The wizard requires that we designate at least one dimension for a cube. We can designate fields that provide isolated facts and do not belong in any particular hierarchy, such as the Store Type in our example, as dimensions with a single level. Rather obviously, our cube will be more useful for reports if we design some of the fields as levels to "roll up" to higher levels and dimensions.

To create a level within a dimension, drag each field from the Source Fields list onto an existing dimension or level in the Dimensions box, as shown in the following steps. To rename a selection, simply right-click and select Rename from the shortcut menu that appears. (The "click label and wait" routine also enables the direct typing of changes.)

  1. Move the selections shown in Table 2 from the Source Field list on the left to the appropriate position in the Dimension list on the right. (To correctly place the dimensions/levels under the dimensions, use the "template" guide that automatically adjusts itself to remain at the bottom of the existing Dimension list for each new dimension created.)

  2. Rename each selection (the "source field" table name), with the suggested New Name below it, as shown in Table 2.

    Table 2 Initial Dimensions List with Suggested New Names.






    Source Field Table Name





    New Name




    Product Name

    Source Field Table Name





    New Name


    Sales Country

    Sales State

    Sales City






    New Name


    Store Country

    Store State

    Store City

    Source Field Table Name





    New Name





The OLAP Cube Wizard – Step 2 of 3 dialog box now resembles that partially illustrated in Figure 32.

Figure 32Figure 32 Partial View of Step 2 of 3 dialog box with our selections.

  1. Click Next.

    The OLAP Cube Wizard – Step 3 of 3 dialog box now appears.

  2. Select the Save a cube file containing all data for the cube radio button by clicking it, if necessary.

  3. Select a location in which to save the cube file.

  4. Click Save.

    The OLAP Cube Wizard – Step 3 of 3 dialog box now appears, as shown in Figure 33.

    Figure 33Figure 33 Step 3 of 3 dialog box with cube type selection and file name/location.

With another selection in this dialog box, we decide what kind of cube we want to create. While our choice here depends on several factors in our operating environment, including the amount of data our cube will contain; the type and complexity of reports we plan to create based upon our cube; and the memory, disk space, and other resources on our systems (as well as those of the systems upon which the information consumers will be interacting with our cube). Experience and planning will be our best guides as we develop larger and more complex cubes for various organizational needs.

The Save a cube file containing all data for the cube option creates a separate cube file on our PCs, retrieving all the data we have designated within our cube design, and storing it in this file. This selection is not appropriate in all situations, but might represent a good choice when the following occur:

  • We are constructing and generating a cube for frequently changing interactive reports.

  • The amount of disk space used by the report is not a limiting concern.

  • We want to store the cube on a network server as a standalone source that information consumers can access to create their own reports (an alternative but often innovative use for a "local" cube. Local cubes are also great to use for training sources for fledgling report writers.)

A cube file can act as an intermediate source of data from the original relational database that excludes source data to which we might want to prevent access. A cube file can also provide a snapshot of some or all of the source database to facilitate offline access and analysis, either for a consumer community (for instance, on an isolated separate network), or for a sole remote consumer or consumers.

As in most scenarios of variable processing and storage scenarios, resource and speed tradeoffs are factors to consider. With the Save a cube file containing all data for the cube option, we can expect more time and resources to be necessary for the initial creation of the cube; but read operations, such as opening and modifying reports, will likely be faster (although cube size is a factor to consider in read speeds). In addition, the fact that the cubes we generate are self-contained is often a deciding factor for the selection of the Save a cube file containing all data for the cube option.

The sheer amount of the data we include in the cube, together with the number of dimensions and levels we attach to the model, are key factors in predicting ultimate cube size. Flatter hierarchies and filtered data selections are considerations in reducing cube size, as are other cube type options that can be selected on the Step 3 of 3 dialog box. A close study of the options and prudent design of the cube, combined with testing in an appropriate development environment (and well-facilitated by the ability to create and modify local cubes quickly and easily, as I have emphasized), contribute heavily to efficient cube generation, delivery, and overall operations.

For more information regarding the details of the various choices that appear on this dialog box, as well as optimization techniques for cube building in general, see the Books Online that are installed with the Typical MSSQL Server 2000/Analysis Services installation (or that can be accessed on the installation CDs or on the Microsoft MSSQL Server website).

  1. Click Finish.

    The Save As dialog box appears, prompting us to name the definition file of the OLAP query (.oqy).

  2. Name the file Tutorial-LocalCube, and navigate to store it in a convenient place.

    The Save As dialog box appears, as shown in Figure 34.

    Figure 34Figure 34 Save As Dialog box, with location indicated for the new definition file.

Microsoft Query prompts us to save the cube definition (.oqy) file, which is separate from the cube file that we create to store data. We can reuse the .oqy file in Excel for report creation or for other possible purposes later. When we chose the Save a cube file containing all data for the cube option at the last dialog box, a file with a .cub extension was "scheduled" to be created in a location to be specified. The .cub file actually contains the data for the cube and is not created immediately when we click Finish. In our case, it is created when we save the cube definition as a file; once Microsoft Query creates the OLAP query file, it hands off instructions to the PivotTable Service to use the newly saved definition to kick off creation of the local cube.

To modify our initial cube design, we have only to open the .oqy file to initialize the OLAP Cube Wizard once more. For more details regarding the .oqy files, see the Microsoft Query Online Help.

  1. Click the Save button in the Save As dialog box.

The .oqy file is quickly saved, and the Creating Offline Cube dialog box appears and remains until the cube is created, confirming that the build is taking place.

Microsoft Excel returns, in which we are greeted by the PivotTable and PivotChart Wizard – Step 3 of 3 dialog box, as shown in Figure 35.

Figure 35Figure 35 PivotTable and PivotChart Wizard – Step 3 of 3 dialog box.

  1. Choose where to place the new PivotTable on the current worksheet or on a new worksheet entirely.

  2. Click Finish.

We see the standard PivotTable "map" appear, signaling that 1) we have a connection to the new cube; and 2) that the cube is ready to be reported upon using standard PivotTable report procedures. The PivotTable report appears, as shown in Figure 36.

Figure 36Figure 36 PivotTable report—ready for reporting action.

The cube is now ready for reporting; and, from the perspective of a reporting application, is in many ways identical to a server-generated cube.

  1. Save the Excel worksheet as desired.

Keep in mind that we can call Microsoft Query at any time to rapidly edit the initial .oqy file—to make modifications based upon the results obtained in reporting efforts or as new requirements arise from the information consumers who test the new cube design in development. A quick rebuild of the cube will implant any changes, giving us the opportunity to immediately test for desired results again.

  • + Share This
  • 🔖 Save To Your Account

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information

To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.


Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.


If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information

Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.


This site is not directed to children under the age of 13.


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information

If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information

Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents

California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure

Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact

Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice

We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020