Search code examples
mdxduplicate-datardlcross-joingranularity

mdx crossjoin over dimention hierarchy with granular measures results in duplicate statistics of Reporting Services data set


I'v built a SSRS revenue report in Visual Studio 2005 over SSAS 2008 R2 Qube data source for deployment on MS SharePoint 2005 Server. It runs fine (in rus.):

(oops, can not post image below 10 points reputation)

But the problem is that report's mdx outputs duplicate x2/x3/x4/x10 statistics in different measures, which are loaded into different levels of calendar hierarchy (some plans has per annum granularity, other quarterly, fact data lay in the leafe level of exact dates). Here is mdx-code abstract:

/* Revenue plan-fact report for business units 
   (simplified translated abstact,
    initially built for new 2015 and old clients) */

    /*============================================================================
      CALCULATED MEASURES
      ============================================================================*/

        WITH    
        MEMBER [is new client] AS 
        CASE       
        WHEN [Clients].[First contract calendar].CURRENTMEMBER = 
             [Clients].[First contract calendar].[Year START DATE].&[2015-01-01T00:00:00] 
        THEN 1 ELSE 0 END       

        MEMBER [Measures].[New clients - Revenue Plan] AS 
               CASE WHEN [is new client] = 1 
               THEN [Measures].[New clients - Revenue Plan]
               ELSE null END

        MEMBER [Measures].[New clients - Revenue Fact] AS 
               CASE WHEN [is new client] = 1 
               THEN [Measures].[New clients - Revenue Fact]
               ELSE null END

        MEMBER [Measures].[New cients - contracts Plan] AS 
               CASE WHEN [is new client] = 1
               THEN [Measures].[New cients - contracts Plan]
               ELSE null END

    /*============================================================================
      CONSTRACT DATA SET
      ============================================================================*/

        SELECT {[Measures].[New clients - Revenue Plan],
                [Measures].[New clients - Revenue Fact],
                [Measures].[New cients - contracts Plan]} ON COLUMNS,

        --exists(
        --nonempty(    
        CrossJoin(
                  -- dimention of client's first contract calendar 
                  -- (we need it to calculate measure of new/old client flag):
                  -- drill down from years through quarters to monthes

                  Hierarchize(DrilldownMember({
                              {DrilldownLevel({[Clients].[First contract calendar].[Year START DATE]})}},
                                              {[Clients].[First contract calendar].[Quarter START DATE]})
                              -{[Clients].[First contract calendar].[Month START DATE].&[1899-12-30T00:00:00]}),

                  -- dimention of company's business structure (to show in report rows)

                  Hierarchize(DrilldownMember({
                              {DrilldownLevel({[Business structure].[Hierarchi].[ALL]})}},
                                              {[Business structure].[Hierarchi].[LV1].&[3]})
                              -{[Business structure].[Hierarchi].[ALL],                            
                                [Business structure].[Hierarchi].[LV1].&[3],
                                [Business structure].[Hierarchi].[LV2].&[3]})               
                  )
        --))        
        ON ROWS 

        FROM [DWH_FD_client_count]

which results in data set with doubling statistics in different levels of calendar hierarchy:

(oops, can not post image below 10 points reputation)

I've tried exists(), nonempty(), nonemptycrossjoin() and filter() functions - but it all leads to statistics gaps for a part of business units. I suggest the root problem is Qube's measures' granularity. But I can't influence that, I need to make figures fine on the side of Report Server's mdx. May be, I need to modify drilldown block for [Clients].[First contract calendar] measure hierarchy.

HELP me please, folks! I can't overcome this probolem for two weeks by now


Solution

  • Here is solution, which worked for me. The problem appeared to be in the hierarchy drilling of [Clients].[First contract calendar] dimention, which coused wrong crossjoin of it's levels with output of excessive rows and doubling statistics. To make mdx work fine I've just replaced this code block:

    Hierarchize(DrilldownMember({
                              {DrilldownLevel({[Clients].[First contract calendar].[Year START DATE]})}},
                                              {[Clients].[First contract calendar].[Quarter START DATE]})
                              -{[Clients].[First contract calendar].[Month START DATE].&[1899-12-30T00:00:00]})
    

    with one hierarchy attribute call only:

    [Clients].[First contract calendar].[Month START DATE]
    

    Note: the output data set in the Reporting Services produces not Monthes column only, but all it's parent hierarchy levels also: Years and Quarters, which I tried to produce with functions Drilldownmember() and Drilldownlevel() initially