Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


SSAS Median Function


SSAS Median Function

Author
Message
ken-467489
ken-467489
Forum Newbie
Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: General Forum Members
Points: 5 Visits: 20
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.
cees van diermen
cees van diermen
Valued Member
Valued Member (57 reputation)Valued Member (57 reputation)Valued Member (57 reputation)Valued Member (57 reputation)Valued Member (57 reputation)Valued Member (57 reputation)Valued Member (57 reputation)Valued Member (57 reputation)

Group: General Forum Members
Points: 57 Visits: 83
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 School 4,708
High School 10,320
Graduate Degree 10,603
Partial College 16,623
Bachelors 18,144



QED

Hope this helps you out.

Cees
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search