Explain about MDX in MSBI

A query language used to collect data from multidimensional databases is MDX (Multi-Dimensional eXpressions). More specifically, MDX is used to query Research Services for multidimensional data and supports two distinct modes.

MDX is not a proprietary language; it is a query language based on specifications that are used to recover data from SSAS databases. MDX is part of the Microsoft supported OLE DB for OLAP specification.

They could refer either to the MDX query language or to MDX expressions if one refers to MDX. While the language of the MDX query has a syntax close to that of MSBI SQL, it is substantially different,More info go through MSBI Course.

Concepts of Fundamentals in MSBI

Typically, a multidimensional database is referred to as a cube. The cube is the basis of a multidimensional database, and more than two dimensions are usually used in each cube.

A set may contain zero tuples, one tuple or more. A zero-tuple set is known as an empty set. An empty set is depicted as follows.

<pre>{ } <pre>{ }

{Customer.Country.Australia, Customer.Country.Canada,Customer.Country.Australia}</pre> {Customer.Country.Australia}</pre>

This collection includes two instances of the Customer.Country.Australia. tuple. Since a member of a dimension alone forms a tuple, in MDX queries it can be used as such. Likewise, if there is a tuple that only one hierarchy defines, we do not need the parentheses to define it as a set. We do not need curly braces to show when there is a single tuple defined in a question.

Queries on MDX in MSBI

For an MDX query, the syntax is as follows.

<pre>[WITH <formula expression> [, <formula expression> …]]] WITH <formula expression>

SELECT [<axis expression>, [<axis expression> …]]]

[<cube expression>]] FROM

[WHERE]</pre> [slicer expression]

The keywords WITH, Pick, FROM, and WHERE are referred to as clauses, along with the phrases that accompany them. Anything defined in square brackets in the previous MDX query template means that it is optional; that is, in an MDX query, that portion of the query is not mandatory. We can see that the WITH and WHERE clauses are optional because inside square brackets they are enclosed.

For custom calculations and procedures, the WITH clause is usually used.

The Pick statement and definition for the axis in MSBI

A subset of the multidimensional data in an OLAP cube is retrieved using the MDX SELECT statement. The SELECT statement in MSBI SQL allows one to determine which columns in the row data we retrieve will be included, which is viewed as two-dimensional data. You have the X and Y axes if you consider a two-dimensional scheme of coordinates. For COLUMNS, the Y-axis is used and ROWS uses the X-axis. The SELECT statement in MDX is defined in a way that allows data with more than just two dimensions to be retrieved. Indeed, MDX gives you the ability to retrieve data on one, two, or multiple axes.

The SELECT statement syntax is:

SELECT [<axis expression>, [<axis expression> …]]]

After the Pick, the axis expressions defined to relate to the dimension data that we are interested in recovering. As the information from these dimensions is projected onto the respective axes, these dimensions are referred to as axis dimensions.

The syntax for expression is-axis.

<pre><axis expression>:= < set > ON (axis | AXIS(axis number) | number of the axis)</pre> < set > ON (axis | AXIS(axis number)

In order to retrieve multidimensional result sets, Axis dimensions are used. The set, a set of tuples, is defined to form a dimension of the axis. In the SELECT statement, MDX gives you the option to define up to 128 axes. Aliases have the first five axes. COLUMNS, ROWS, PAGES, SECTIONS, and CHAPTERS are them. It is also possible to specify axes as a number, so you can specify more than five dimensions in your SELECT statement.

Let’s take the example below:

Pick Measures.[Amount of Internet Sales] ON COLUMNS,

[Customer].[Country]. ON ROWS Participants,

[The Product].[The Product Line].MEMBERS ON PAGES

FROM [Works of Adventure]

In the SELECT statement, three axes are defined. Steps, consumers, and product data from dimensions are projected on to the three axes to form the dimensions of the axis.

This sentence may be written equivalently as follows.

SELECT Measures.[Amount of Internet Sales] ON 0, 0,

[Customer].[Country].MEMBERS ON 1, 1, ON 1, ON 1, ON 1, ON 1,

[The Product Line].[The Product Line].MEMBERS ON 2

FROM [Works of Adventure]

Dimensions of Axis in MSBI

When we describe a SELECT sentence, the axis dimensions are what we construct. For each dimension, a SELECT statement defines a set; COLUMNS, ROWS, and additional axes. Axis dimensions retrieve and hold data for multiple members, not just single members, unlike the slicer dimension.

The Definition of the FROM Clause and Cube in MSBI

In an MDX query, the FROM clause specifies the cube you retrieve and evaluate data from. In an MSBI SQL query, it’s close to the FROM clause where you define a table name. For any MDX query, the FROM clause is a requirement.

The FROM clause’s syntax is:

<cube expression> from FROM

The cube expression denotes a cube’s name or a subsection of a cube that we want to retrieve data from. We can specify more than one table in MSBI SQL’s FROM clause, but only one cube name can be specified in the MDX FROM clause.

That is, all portions of axis expressions are obtained from the sense of the cube defined in the “FROM” clause.

[Internet Sales Amount] ON COLUMNS Pick [Measures].

FROM [Works of Adventure]

This is a valid MDX query that retrieves information on the X-axis from the [Internet Sales Amount] measure. The measured data is retrieved from the [Adventure Works] cube background. While the FROM clause limits us to operate with only one cube or part of a cube, using the MDX LookupCubefunction, we can retrieve data from other cubes.

If there are two or more cubes with similar dimension members, the LookupCubefunction uses the common dimension members to retrieve steps outside the range of the current cube.

The WHERE Definition for Clause and Slicer in MSBI

We issue queries that return only portions of the total data available in a given table, collection of joined tables, and/or joined databases in any relational database work that we do. This is achieved using MSBI SQL statements that define what information we are doing and do not want to return as a result of running your query.

Here is an example of an unrestricted MSBI SQL query containing sales details for goods on a table called Product:


Product from FROM

In MSBI SQL, the two columns chosen are now the COLUMNS and ROWS axes. The state in the MSBI SQL WHERE clause, which is a string analogy, is translated into the MDX WHERE clause, which refers to a cube slice that includes silver-colored products.

The Dimension of the Slicer in MSBI

When you describe the WHERE sentence, the slicer dimension is what you construct. It is a filter that excludes unwanted components and measurements.

Any axis in the cube contains the slicer dimension, including those that are not specifically included in any of the axes requested. In the slicer axis, default hierarchy members that are not included in the query axes are included. MDX will evaluate such tuples as a collection when there are tuples defined for the slicer axis and the results of the tuples are aggregated based on the measures used in the question and the aggregation function of that particular measure.


I hope you have an idea by now about MDX in MSBI. You can learn more about MDX expressions and other functions through MSBI training.

Big Data,ios,android,Spark

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store