Wednesday, 5 April 2017

Learn MDX with Me – Part - 2

Introduction
Now we are continuing our journey of MDX. Here we are going to see couple of concept and going to write our first MDX Query. Hope the session is very interesting.

Members, Sets and Tuples

Members:

A member comes from Hierarchy levels or from Attributes level.




If we drag the members into MDX editor we can find.

-- Memebrs of Attributes
[Dim Time].[Quarter Name].&[Quarter 1, 2017]
-- Memebrs of Hierarchy
[Dim Time].[Hierarchy].[Year].&[2017-01-01T00:00:00].&[2017-01-01T00:00:00]

Sets:

Members comes from the Same Hierarchy is called Sets. We want to mean that when we put together all the members of same Hierarchy it is called Sets.





{[Dim Time].[Quarter Name].&[Quarter 1, 2017],
 [Dim Time].[Quarter Name].&[Quarter 2, 2017],
 [Dim Time].[Quarter Name].&[Quarter 3, 2017],
 [Dim Time].[Quarter Name].&[Quarter 4, 2017]}

We can see that all the members came from same Hierarchy named [ Quarter Name ]

Tuples:

It is the just opposite of Sets.
Here the members came from different Hierarchy and combined





({[Dim Time].[Quarter Name].&[Quarter 1, 2017],
  [Dim Time].[Quarter Name].&[Quarter 2, 2017],
  [Dim Time].[Quarter Name].&[Quarter 3, 2017],
  [Dim Time].[Quarter Name].&[Quarter 4, 2017]},
 {[Dim Time].[Week Name].&[Week 1, 2017],
  [Dim Time].[Week Name].&[Week 10, 2017],
  [Dim Time].[Week Name].&[Week 11, 2017],
  [Dim Time].[Week Name].&[Week 12, 2017]})

Here we can see that all the members came from different Hierarchy named [ Quarter Name ] and [ Week Name ]


Basic MDX Structure


SELECT Sets/Tuples/Member ON Columns,     -- Dimension-0
       Sets/Tuples/Member ON Rows         -- Dimension-1
        ..........                        -- Dimension-2
        ..........                        -- Dimension-3
        ..........                        -- Dimension-4                    
        ..........                        -- Dimension-5
        ..........                        -- Dimension-n
FROM   <Cube Name>
WHERE  <Condition>

Here there is multi dimension but our system can support only TWO dimension and that is Columns and Rows.

The simplest MDX Query 

SELECT
FROM   <Cube Name>

If we see it carefully we can find that there is no axis defined on it.
SELECT
FROM   [CUBESales]

Here the output is Undefined.




This learning session will be continued. Please make your interest by commenting it.



 Posted by: MR. JOYDEEP DAS


No comments:

Post a Comment