Solved

MDX Expression for a Cube

Posted on 2012-04-10
2
476 Views
Last Modified: 2012-04-26
I have a fact table with the following structure:
DateID
BuyerID
SellerID
Amount

Both BuyerID and SellerID are UserID, meaning a user can be both a Buyer and a Seller.  Moreover, a Buyer can sell something to himself.  In this case, BuyerID and SellerID are the same.

Now this structure has been converted to a cube.  I want to create an Calculation member to show the total Amount of sales of a single user.  This amount should NOT include those Amount Sales that has the same BuyerID and SellerID (whatever the user sells to himself shouldn't be counted into the Total Amount of sales of the user).

How can I create this Calculation member?  Thanks.
0
Comment
Question by:thomaszhwang
2 Comments
 
LVL 15

Accepted Solution

by:
Tim Humphries earned 500 total points
ID: 37831958
Hi,

It would help if you posted the structures of the user hierarchies you have created. In the absence of these I will make some assumptions:

As you have User id acting in two roles I'll assume that you have hierarchies similar to:

[User].[Seller] and
[User].[Buyer] related to the fact table

I'll take the Amount as being [Measures].[Sales Amount]

As you want the Sales, then I'll assume that in your query you have [User].[Seller].Members on rows - this is important as we need to know  the Seller.Currentmember

You should then be able to use a calculation similar to:

MEMBER [Measures].[Seller Only Amount] As [Measures].[Sales Amount] - ([Measures].[Sales Amount], LINKMEMBER([User].[Seller].CURRENTMEMBER, [User].[Buyer]))

This should find the sales associated with the user as a buyer in the current tuple where the user is the seller i.e. where the user is both buyer and seller.


Tim
0
 

Author Closing Comment

by:thomaszhwang
ID: 37900437
Thanks.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Query Optimization 14 42
kill process lock Sql server 9 45
SSRS Subscription jobs disabled, yet still running 4 31
T-SQL: New to using transactions 9 19
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

813 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now