Solved

MDX Expression for a Cube

Posted on 2012-04-10
2
474 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

919 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

22 Experts available now in Live!

Get 1:1 Help Now