Any MDX Guru’s out there?

Update – 30 May 2009

Thanks to a comment by Mathias (and followup email – thanks dude) the following code as a calculated measure in the OLAP cube did exactly what I needed:

([Measures].[Costsum],[KeepDim1].currentmember,[KeepDim2].currentmember,[LoseDim1].currentmember,[LodeDim2].defaultmember)

/

([Measures].[QtyAVG],[KeepDim1].currentmember,[KeepDim2].currentmember,[LoseDim1].currentmember,[LodeDim2].defaultmember)

The trick was you have to specifically exclude all dimensions you dont want included in the calc usinf defaultmember otherwise the calc will use currentmember for it.

—End update

So im struggling with MDX and SAS at the mo.

I have a cube that has a number of dimension, for example:

  • Product
  • Customer
  • Period
  • Location
  • Sales Person

And I have some measures

  • Cost
  • Quantitiy

Now I want to calculate unit cost (i.e Cost / Quantitiy) but (and here is my problem) I only ever want to calculate it based on a combination of the Product and Sales Person dimensions.

So if only Product and Sales Person are added to the cube view (in WRS) then I can just divide Cost by Quantity.

But as soon as I add Organisation (or any other dimension), the cost gets split by the multiple organisation dimension members and therefore the dynamic calculation doesnt work, so I need to hardcode the formula to only pick up the cost based soley on the Product and Sales Person dimensions.

Any suggestions (using custom measures in OLAP cubes, or custom data item in Information Maps, im easy)?

Share
Tags:

One Response to Any MDX Guru’s out there?

  1. Matthias Ender on May 15, 2009 at 10:04 am

    Hi,
    here is one way that might work:

    create a calculated measure that checks which member of each of the non-allowed dimensions is part of the current cell. If it’s not the All member, return a null:

    IIF([Customer].currentmember IS [Customer].defaultmember
    AND
    [Period].currentmember IS [Period].defaultmember
    AND
    [Location].currentmember IS [Location].defaultmember
    ,
    [Measures].[Cost] / [Measures].[Quantity]
    ,
    NULL
    )

    Matthias Ender
    SAS OLAP Server

Leave a Reply

Your email address will not be published. Required fields are marked *

*