0% found this document useful (0 votes)
17 views2 pages

Additionnal Exercise For MDX Syntax

Uploaded by

Rouaida Hentati
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views2 pages

Additionnal Exercise For MDX Syntax

Uploaded by

Rouaida Hentati
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Example 1

MDX query to retrieve sales data

SELECT

[Time].[Year].[2019] ON COLUMNS,

[Product].[Category].Members ON ROWS,

[Measures].[Sales] ON PAGES

FROM

[SalesCube]

WHERE

[Location].[Country].[USA]

The SELECT clause specifies the dimensions and measures that will be included in the result set. In
this query:

[Time].[Year].[2019] ON COLUMNS: This places the Year 2019 on the columns axis. It indicates that
the columns of the result set will represent the sales data for the year 2019.

[Product].[Category].Members ON ROWS: This places the members of the Product Category


dimension on the rows axis. It indicates that the rows of the result set will represent the different
product categories.

[Measures].[Sales] ON PAGES: This places the Sales measure on the pages axis. The pages axis is
another way to organize data, typically used for additional dimensions or scenarios.

The FROM clause specifies the OLAP cube from which the data will be retrieved. In this case, it's the
"SalesCube."

The WHERE clause filters the data based on a specific condition. In this query:

[Location].[Country].[USA]: This filters the data to include only sales data for the country "USA." It's
restricting the result set to sales transactions that occurred in the United States.

Putting it all together, this MDX query is asking for sales data for the year 2019, broken down by
product categories, and filtered to include only sales transactions in the USA. The result set will have
columns representing months in the year 2019, rows representing different product categories, and
the Sales measure providing the actual sales data. The query is a way to explore and analyze sales
performance within the specified dimensions and criteria.
Example 2: Analyzing Sales Performance

Consider a fictional OLAP cube named "SalesCube" that contains data about sales transactions. The
cube has dimensions for Time, Product, and Location, with measures such as Sales and Quantity.

Write an MDX query to retrieve the total sales amount for each product category in the year 2022.
Assume that the Time dimension has levels for Year, Quarter, Month, and Day, and the Product
dimension has levels for Category and Subcategory.

Your MDX query should include the following elements:

 The [Time].[Year].[2022] on columns to filter data for the year 2022.


 The [Product].[Category].Members on rows to display sales data for each product category.
 The [Measures].[Sales] as the measure to analyze.

Example 3: Monthly Quantity Analysis

Assume you have an OLAP cube named "InventoryCube" containing data about product quantities in
stock. The cube has dimensions for Time, Product, and Location, with measures such as Quantity.

Write an MDX query to retrieve the monthly quantity of each product subcategory for the year 2023.
Assume that the Time dimension has levels for Year, Quarter, Month, and Day, and the Product
dimension has levels for Category and Subcategory.

You might also like