Question

I have a measure, that's a distinct count on a field in the fact table. I'm now trying to create a calculated member which filters that count based on certain criteria.

What I have now is as follows,

SUM({[Transactions].[Transaction Type].&[1],[Transactions].[Transaction Types].&[2]}, [Measures].[Distinct Count])

This returns the distinct count for type 1 + distinct count for type 2

What I'm looking for is the distinct count IN (1,2)

For a single value/filter, I've used

([Measures].[Distinct Count],[Transactions].[Transaction Types].&[20])

The above works fine for 1 value, however I'm not sure how to write the MDX code expression for 2,3,4, etc. values

Thank you for any help.

Was it helpful?

Solution

I seem to have figured this out,

Aggregate(
 {
  ([Transactions].[Transaction Types].&[1]),
  ([Transactions].[Transaction Types].&[4])
 },
 [Measures].[Distinct Count]
)

Validating the cube results above against a SQL query using IN (1,4) on the fact table returns the same result.

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