Question

I'm trying to get calculated measure while evaluating Pentaho Analyser.

Point: Need a measure with condition. My code:

IIf ([Product].CurrentMember Is [Product].[Food], [Unit Sales], 0)

So I get:

Drinks 0

Food 14

Else 0

End it works only until [Product] dimension is present on rows or columns.

But when I insert another slicer, and remove [Product] ( [Partner] for example) I get:

IBM 0

MS 0

Apple 0

Instead of:

IBM 7

MS 2

Apple 5

I know, the main problem is CurrentMember property, and it's always zero because there is on CurrentMember on given dimension. Please, do not answer with: 'Filter it on "Food"' because I'm trying to build something more complex and this is a first step.

Is there any trick to get this Measure work?

EDIT: I have 3 dimensions: Product, Partner, Country I need to get via mdx formula calculated measure: [Unit Sales] when it is [Product].[Food] and [Product].[Drink] and it NOT is [Country].[US] and [Country].[DE] but everything else.

Thanks, Best Regards

Was it helpful?

Solution

I am not a specialist for Pentaho/Mondrian, but I would assume the issue is that in your second scenario, the [Product].CurrentMember is the all member of the products, not the Food member, and thus the system behaves as you told it, and returns 0.

From how I understand your question, something like

IIf(
    Count(
        Intersect(
            { [Product].CurrentMember },
            { [Product].[Food], [Product].[Drink], [Product].[All] }
        )
    ) = 1
    AND
    Count(
        Intersect(
            { [Country].CurrentMember },
            { [Country].[US], [Country].[DE], [Country].[All] }
        )
    ) = 0
    [Unit Sales],
    0
   )

should deliver what you want. The trick here is that the intersection between the one-element set containing the CurrentMember and another set can either have one element - in case the CurrentMember is contained in the set -, or zero elements - in case the element is not contained in the set.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top