SSAS Median Function

  • This is going to sound pretty bad but I have never used a function in SSAS to date. I have always been able to work around it and now I have a need to figure the Median of a value but don't know where to even start. Online help was nothing but confusing telling me to create an mdx query, I have to believe it's much easier then that.

    Can someone out there do a bit of hand holding while I get this function to work against an existing measure within the cube.

  • Hello Ken.

    If your intention is to query a cube then Mdx is your query-language. MDX has a built-in Median function you can use. The following (MDX) query results in the medium value for the internet sales count-measure based on the cutomer education.

    with member [measures].[median internet sales count] as

    MEDIAN( [Dim Customer].[Education].[Education].members ,[Measures].[Internet Sales Count] )

    select {[measures].[median internet sales count]} on 0

    from [Adventure Works DW]

    The outcome of this query is:

    median internet sales count

    10603

    By querying the measure Internet Sales Count by Customer Education we can validate that the median has been caluculated correctly.

    select {[Measures].[Internet Sales Count]} on 0,

    order([Dim Customer].[Education].[Education].members, [Measures].[Internet Sales Count], asc) on 1

    from [Adventure Works DW]

    which results in:

    Internet Sales Count

    Partial High School4,708

    High School10,320

    Graduate Degree10,603

    Partial College16,623

    Bachelors18,144

    QED

    Hope this helps you out.

    Cees

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply