开发者

Using MDX Correlation() function to find correlation of 2 dimentional members

开发者 https://www.devze.com 2023-01-22 16:10 出处:网络
I\'m trying to find the Pearson correlation of a single measure between two members of a dimension, but the msdn docs a开发者_如何学JAVAre a bit sparse.Specifically I have a cube with a fact count mea

I'm trying to find the Pearson correlation of a single measure between two members of a dimension, but the msdn docs a开发者_如何学JAVAre a bit sparse. Specifically I have a cube with a fact count measure, a date dimension, and a tool dimension and I'd like to find the correlation of tool X and tool Y over the date dimension.


take a look at the following script (Adventure Works DW 2008 R2):

It will return correlation of [Internet Sales Amount] measure for two different product subcategories ("Mountain Bikes"/"RoadBikes") for months of current date member on rows (Calendar Year 2007 quarters and Calendar Year 2007). I have left other comparable members in comments.

with 
member ActualMeasure    AS  [Measures].[Internet Sales Amount]

member m1 AS 
(
    [Product].[Product Categories].[Subcategory].&[1] -- Mountain Bikes
--  [Sales Territory].[Sales Territory].[Group].&[North America]
--  [Customer].[Gender].&[F]
    ,ActualMeasure
)
member m2 AS 
(
    [Product].[Product Categories].[Subcategory].&[2] -- Road Bikes
--  [Sales Territory].[Sales Territory].[Group].&[Europe]
--  [Customer].[Gender].&[M]
    , ActualMeasure
)
member x as
Correlation
(
    {Descendants([Date].[Calendar].CurrentMember,[Date].[Calendar].[Month]) } as dates
    , m1
    , m2
), Format_String="Standard"

select
{   x,m1,m2 } on 0,
{
    Descendants
    (
        [Date].[Calendar].[Calendar Year].&[2007]
        , [Date].[Calendar].[Calendar Quarter]
    )  
    ,[Date].[Calendar].[Calendar Year].&[2007]
} on 1
from [Adventure Works]

HTH,

Hrvoje Piasevoli

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号