Wednesday, 20 November 2013

Visual Total in MDX

We can make use of Visual Total Function in MDX for getting totals of members used in the query at parent level.

Example 1:

Query below gets
  1. Visual total for year 2007 which consists of only two months "Internet Sales Amount" i.e August and September 2007.
  2. Visual total for August 2007 which includes only two days "Internet Sales Amount" i.e. 1 & 2 August. &
  3. Visual total for September2007 which includes only one day's "Internet Sales Amount" i.e. 14 September.

Because only these month's and Day's are part of SET specified in the query.

SELECT
   VisualTotals
   (
      {
        [Date].[Calendar].[Calendar Year].&[2007]
        ,[Date].[Calendar].[Month].&[2007]&[8]       
        ,[Date].[Calendar].[Date].&[20070801]:[Date].[Calendar].[Date].&[20070802]
        ,[Date].[Calendar].[Month].&[2007]&[9]
        ,[Date].[Calendar].[Date].&[20070914]
      }
      , '* - Visual Total'
   ) ON 1
, [Measures].[Internet Sales Amount] ON 0
FROM [Adventure Works]

--VISUALTOTALS( «Set», «Pattern» )




No comments:

Post a Comment