Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Calculating "Median"(or any other aggregate function)  in OLAP cube****Urgent***$$$***

Posted on 2003-12-04
4
Medium Priority
?
1,106 Views
Last Modified: 2012-09-07
Hello all,

Myself and few other guys are working on this problem from past few days but no break-through yet.

We are trying to figure out calculating "Median"

Here is the business problem:

In "Foodmart" database (standardly delivered with MS SQL server Analysis Services)

1. I picked a customer: customer_id = 139 (Cusromer Table). Belongs to Coronado (city), CA (State)

2. for this customer we have 3 sale records (in sales_fact_1997) table

product_id      time_id      customer_id      promotion_id      store_id      store_sales      store_cost      unit_sales
487            695      139            0            24            $7.80            $2.89            3
970            695      139            0            24            $12.44            $5.22            4
1080            695      139            0            24            $8.76            $4.20            4

Lets calculate (Only for customer 139)

Total No of records      : 3
Total Store Sales      : $7.80 + $12.44 + $8.76 = $29
Average Store Sales      : $29/3 = $9.67
Median Store Sales      : $7.80, $8.76, $12.44 = $8.76

Now I was trying to get the same result in Analysis Services

I created a formula under "Sales" cube

MedianCustomerSales = Median({[Customers]},[Measures].[Store Sales]) Hoping it would work

However when I do a browse data for Sales cube (Also creted a pivot table in excel and tried)

Surprisingly MedianStoreSales value os also displayed as $29.

"Why?"

If you ever worked with Median or StdDev type of functions (caculated based on population) please help.

Question 2: I do not want to limit calculating Median by Customer, I want to give option to see "median store sales" based on the dimention user select while browsing the

data like Department or Product Or Store. How?

Please do call me 443-983-3133 or mail me at ksurya@inventumtech.com

Regards
Surya
0
Comment
Question by:ksurya
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 11

Expert Comment

by:SweatCoder
ID: 9880185
if the median stuff isn't working in sql, write a vb com dll to return the correct value, then call the dll from sql server 7 or 2000. i've done stuff like this many times.

for the 500 points, i'll write it for you, both the sql side and the vb dll side.

the only sql part i'll write is calling the dll, passing in all values, and getting back the median. you do the rest.

if you're interested, "Accept" this answer and see my profile to get my email.
0
 
LVL 8

Accepted Solution

by:
Dishan Fernando earned 2000 total points
ID: 9880260
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Ready to get certified? Check out some courses that help you prepare for third-party exams.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question