Ask PL-SQL Expert

Performing OLAP with SSAS and MDX

Objective:

Demonstrate use of SSAS interactive features and MDX queries to perform OLAP operations;

Estimated time to complete: 40 min reading +45-50 min. solve queries

Tasks:

In this assignment we are going to use perform OLAP operations on a cube called DS715 located in a multidimensional database called SSAS_DS715 that has been defined based on the tables in the database given by the description below:

Tb_Supplier(Supp_ID, Name, City, State)
Tb_Consumer(Con_ID, Name, City, State)
Tb_Product(Prod_ID, Name, Product_Category, Product_Line, Product_Packaging)
Tb_Offers(Supp_ID, Prod_ID, Quantity, Price)
Tb_Requests(Con_ID, Prod_ID, Quantity, Price)
Tb_Transactions(Tran_ID, Supp_ID, Con_ID, Prod_ID, Quantity, Price)

The dimensions of the cube are: Tb_Supplier, Tb_Consumer and
Tb_Product.

Measure groups are: Tb_Offers, Tb_Requests and Tb_Transactions.

The following dimension hierarchies have been defined within the dimensions:

Tb_Supplier: State > City > Name Tb_Consumer: State > City > Name Tb_Product: Product_Packaging > Name
Product_Category > Product_Line > Name

Performing OLAP
Can be done in two ways:
- Using the interactive Browse interface to build OLAP queries;
- Using the Multidimensional Expressions (MDX) syntax.

Interactive OLAP

Microsoft SQL Server Analysis Services (SSAS) provides a very intuitive interactive browse feature that is based on the drag-and-drop metaphor.

Basic understanding of cubes with dimensions, measures, and hierarchies is sufficient for creating OLAP queries.

The queries created can also be scripted which means the equivalent MDX query is generated, which can then be visualized, copied and tweaked for further execution. That makes the feature a useful tool to also learn the actual MDX syntax.

After you logged-in into Microsoft SQL Server Analysis Services do the following:

1. Expand the SSAS_DS715 multidimensional database.

2. Expand the Cubes folder.

3. Right-click on the DS715 cube and choose: Browse.

4. Expand the Measures tree and the Tb_Consumer, Tb_Product, Tb_Supplier dimension trees. The result will look like below:

5. Drag and drop measure and dimension attributes on the blank center area to build a query.

Click right on the blank center area and chose"Clear Grid" to abandon and delete the current query and its result.

When finished execute the query by clicking on the "Execute Query" icon; i.e. the third from the right with a red exclamation mark.

Note query result will show automatically as soon as a measure attribute is drag on the surface.

The result may be like:

6. Click on the leftmost top icon, tool tip "Design Mode", to create equivalent MDX code. The code looks like:

7. Carefully study the generated code, remove all optional syntax elements and arrange in easy to read format.

8. Move the code in a new query window and execute.

9. Make changes and create new queries.

10. Repeat the process until you become and MDX expert.

Multidimensional Expressions (MDX)

Multidimensional Expressions (MDX) is a query language specialized for OLAP that is designed to manipulate and retrieve multidimensional data in Microsoft SQL Server Analysis Services (SSAS).

MDX is similar in many ways to SQL, but it allows expressing queries on cube data in terms of dimensions, hierarchies and measures. Those are the higher level abstractions business analysts are comfortable to work with during their OLAP sessions.

However, MDX is not an extension of the SQL language and is different from SQL in many ways. In order to create MDX queries that return and format multidimensional data, we need to understand basic concepts in MDX and dimensional modeling, MDX syntax elements, MDX operators, MDX statements, and MDX functions.

While it not our objective to present here the details of the MDX syntax, we can get a good sense of how MDX works and how to start building our own MDX queries by looking at some representative samples.

For a presentation of MDX check for example the book from APress, Pro SQL Server 2012 BI Solutions, by Randal Root and Caryn Mason (APress, 2012).

Check the MDX solutions to the sample queries from Assignment#4.

Test and run each query below against the DS715 located in the SSAS_DS715 database and compare the results with the sample queries from Assignment#4.

--apex - grand total
SELECT { Measures.[Quantity - Tb Transactions], [Measures].[Tb Transactions Count],
Measures.[Price - Tb Transactions] } ON COLUMNS FROM DS715

--base
SELECT NON EMPTY {
[Measures].[Price - Tb Transactions],
[Measures].[Quantity - Tb Transactions] } ON COLUMNS, NON EMPTY {
([Tb Supplier].[Name].[Name].ALLMEMBERS * [Tb Consumer].[Name].[Name].ALLMEMBERS *
[Tb Product].[Name].[Name].ALLMEMBERS ) } ON ROWS FROM DS715
--aggregates by product SELECT NON EMPTY {
[Measures].[Quantity - Tb Transactions], [Measures].[Tb Transactions Count],
[Measures].[Price - Tb Transactions] } ON COLUMNS, NON EMPTY {
[Tb Product].[Name].[Name].ALLMEMBERS } ON ROWS
FROM DS715
--aggregates by products sold to consumers in Wisconsin? SELECT NON EMPTY {
[Measures].[Quantity - Tb Transactions], [Measures].[Tb Transactions Count],
[Measures].[Price - Tb Transactions] } ON COLUMNS, NON EMPTY {
[Tb Product].[Name].[Name].ALLMEMBERS } ON ROWS FROM [DS715]
WHERE [Tb Consumer].[State].&[Wisconsin]
--Quantity of milk sold by each supplier from Wisconsin? SELECT NON EMPTY {

[Measures].[Quantity - Tb Transactions]} ON COLUMNS, NON EMPTY {
[Tb Supplier].[Name].[Name].ALLMEMBERS } ON ROWS FROM [DS715]
WHERE ([Tb Product].[Name].[Name].&Milk, [Tb Supplier].[State].&[Wisconsin])

--Quantity of milk sold by each supplier from Wisconsin in the state of
--Illinois?

SELECT NON EMPTY {
[Measures].[Quantity - Tb Transactions]} ON COLUMNS, NON EMPTY {
[Tb Supplier].[Name].[Name].ALLMEMBERS } ON ROWS FROM [DS715]
WHERE ([Tb Product].[Name].[Name].&Milk, [Tb Supplier].[State].&[Wisconsin],
[Tb Consumer].[State].&Illinois)

More sample queries:

--aggregates by consumers, nulls included and grand total SELECT {Measures.[Quantity - Tb Transactions],
Measures.[Price - Tb Transactions] } ON COLUMNS, [Tb Consumer].[Name].ALLMEMBERS ON ROWS
FROM DS715

--aggregates by consumers, nulls included, no grand total SELECT {Measures.[Quantity - Tb Transactions] ,
Measures.[Price - Tb Transactions] } ON COLUMNS, [Tb Consumer].[Name].[Name] ON ROWS
FROM DS715

--aggregates by consumers, no nulls, no grand total
SELECT NON EMPTY { Measures.[Quantity - Tb Transactions], Measures.[Price - Tb Transactions] } ON COLUMNS,
NON EMPTY [Tb Consumer].[Name].[Name] ON ROWS FROM DS715

--aggregates for select consumers
SELECT NON EMPTY { Measures.[Quantity - Tb Transactions], Measures.[Price - Tb Transactions] } ON COLUMNS,
NON EMPTY {[Tb Consumer].[Name].[Fisher],
[Tb Consumer].[Name].[Gray], [Tb Consumer].[Name].[Hammer]
} ON ROWS FROM DS715

Given the DS715 cube located in the SSAS_DS715 database solve the following queries (all aggregates will be from the Tb_Transactions measure group):

1) Aggregates by combinations of supplier name and product name?

2) Aggregates by supplier states?

3) Number of transactions between supplier-city-consumer-city pairs?

4) Name of each product sold in Wisconsin and quantity of sales for the product?

5) Quantity of sales aggregated by product and supplier state?

6) Quantity of computer sales aggregated by suppliers in Wisconsin?

7) Quantity of auto sales by each supplier from Wisconsin to consumers in Illinois?

8) Quantity of auto sales by each supplier in Madison to consumers in Illinois?

9) Quantity of each product sold by supplier Bernstein to consumers in Chicago?

10) Quantity of milk sold by supplier Bernstein to consumers in Chicago?

11) For each product list quantity sold by suppliers in Madison to consumers in Chicago versus quantity sold by suppliers in Chicago to consumers in Madison (result columns will be: product name, quantity Madison_Chicago, quantity Chicago_Madison?

Return:
Please post your solutions to the queries above in properly formatted MDX syntax (each clause on its own line and with capitalized keyword and operators) in the D2L dropbox created for this assignment.


Attachment:- Assignment Instructions.rar

PL-SQL, Programming

  • Category:- PL-SQL
  • Reference No.:- M92267641
  • Price:- $60

Priced at Now at $60, Verified Solution

Have any Question?


Related Questions in PL-SQL

Complete the following tasksin microsoft access create the

Complete the following tasks: In Microsoft Access, create the database and tables that you identified in W3 Assignment 2. In Microsoft Word, write the SQL statements to create the database and tables. Write SQL statement ...

Purpose of the assessment with ulo mapping the purpose of

Purpose of the assessment (with ULO Mapping) The purpose of this assignment is to develop skills in managing data in databases and to gain understanding of data model development and implementation using a commercially a ...

Continuing the project you have worked on in weeks 1-4 in

Continuing the project you have worked on in Weeks 1-4, in this final week, complete the following tasks: Refine your database and SQL statements by incorporating your instructor's feedback. Verify that the database comp ...

For this assignment you will be provided a database backup

For this assignment, you will be provided a database backup for a database called FinanceDB. You will have to restore this backup to your own version of SQL Server. All of the questions in this assignment relate to the F ...

Assignment - queries functions and triggersaimthe aims of

Assignment - Queries, Functions and Triggers Aim The aims of this assignment are to: formulate SQL queries; populate an RDBMS with a real dataset, and analyse the data; design test data for testing SQL queries; create SQ ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As