Let's say I have a cube with two different distinct count measures, call them Measure1
and Measure2
. Both of these measures contain a common dimension, Dimension1
, which is counted by both measures.
What I need to do is return a distinct count of Dimension1
members that exist in both Measure1
and Measure2
, after appropriate filtering on each measure as required.
I can define MDX queries for both Measure1
and Measure2
individually and get distinct counts, but I need to be able to "overlap" the result to avoid double-counting the members that exist in both sets.
Note: in the actual scenario, there are more than 2 measures involved, and all MDX queries will be dynamically constructed (the user defines which measures and dimension criteria are included).
Can this be done in SSAS/MDX? If not, is there another Microsoft tool/feature that can? The minimum requirement for the system is SQL Server 2008 R2 Standard Edition.
Honestly I have no idea where to start. Google turned up nothing like this (I saw some basket analysis stuff involving a single measure, but I'm unsure if or how to apply that to my scenario). I'm not an SSAS/MDX/BI expert by any means.
There are two alternatives that I can think of:
- Use
DRILLTHROUGH
using the individual MDX queries and (essentially)COUNT DISTINCT
the results. - Use T-SQL on the data warehouse source database. (May be difficult to account for all scenarios efficiently.)
We do have a requirement to also be able to drillthrough, so I'll probably have to implement solution #1 anyway, but it would be nice to have a more efficient way to obtain just the counts, as counts will be needed far more frequently.
Measure1
andMeasure2
, orMeasure2
andMeasure3
, etc.). It also depends on the dimension filters that get applied. As I said, I can define MDX queries to get the set of dimension members for each measure, but then I need toDISTINCT COUNT
on the combination of the results for all the measures required. – Jon Seigel