Wayne Arthurton
Wayne Arthurton

Reputation: 643

Dimension Member as Calculated Measure in MDX

I need to get a dimension member returned as a calculated measure.

Given:

Dimensions

Measures

Relationships

I am trying to do the following:

Create calculated measures that will return the Salesperson with the largest $s credited in a role for a customer. e.g.

| Customer          | Director | Manager | Value |
|-------------------|----------|---------|-------|
| ACME              | Bob      | Fred    | 500   |
| EMCA              | Bob      | Fred    | 540   |
| Universal Imports | Mary     | Joe     | 1000  |
| Universal Exports | Mary     | Fred    | 33    |

I would like to use this as a calculated measure that I can use in any case where Customers are the ROW.

Upvotes: 1

Views: 10543

Answers (1)

Santiago Cepas
Santiago Cepas

Reputation: 4094

If I understand your problem correctly, something along this line should do the trick (of course you'd have to use the proper level, hierarchy and cube names):

   with
    member [Measures].[DirectorTemp] as topcount([Salesperson].[Salesperson].members,1,([Measures].[Credited Value],[Credit Type].[Director],[Customer].currentmember)).item(0).properties("Caption")   
    member [Measures].[Director] as iif([Measures].[DirectorTemp] = [Salesperson].UnknownMember.properties("caption"), null, [Measures].[DirectorTemp])
    member [Measures].[ManagerTemp] as topcount([Salesperson].[Salesperson].members,1,([Measures].[Credited Value],[Credit Type].[Manager],[Customer].currentmember)).item(0).properties("Caption") 
    member [Measures].[Manager] as iif([Measures].[ManagerTemp] = [Salesperson].UnknownMember.properties("caption"), null, [Measures].[ManagerTemp])


    select
        {[Measures].[Director],[Measures].[Manager],[Measures].[Value]} on 0,
        {[Customer].members} on 1
    from MyCube

Upvotes: 1

Related Questions