noup
noup

Reputation: 758

MDX query doesn't filter correctly

I have the following star schema:

Objects       <-> Facts         <-> Simulation
-ObjectID         -ObjectID         -SimulationID
-SimulationID     -SimulationID     
-ObjHierarchy     -Volume
-ObjectType

Now I'm trying to filter the cube using both dimensions:

select [Measures].[Volume] on columns,
[Objects].[ObjHierarchy].[Level 02] on rows
from [DM OC]
where ([Objects].[ObjectType].&[2], [Simulation].[SimulationID].&[52])

However, this returns rows for SimulationID=52 (with values) but also duplicates for SimulationID=53 (with nulls):

ObjHierarchy | Volume
MyObj1       | 12345
MyObj2       | 54321
MyObj1       | (NULL)
MyObj2       | (NULL)

A workaround is to use NonEmpty, however it just seems the cube isn't modeled the right way.

Upvotes: 0

Views: 546

Answers (2)

Marc Polizzi
Marc Polizzi

Reputation: 9375

Can you execute the following :

with member XX as [Objects].[ObjHierarchy].currentMember.Properties( "KEY" )

select { [Measures].[Volume], XX } on columns, [Objects].[ObjHierarchy].[Level 02] on rows from [DM OC] where ([Objects].[ObjectType].&[2], [Simulation].[SimulationID].&[52])

MyObj1 and MyObj2 should not have the same key; otherwise I do not see right now.

Upvotes: 0

orka
orka

Reputation: 1328

It is a usual case and doesn't mean that the cube's model wrong.

In MDX, you should also filter the rows by using any filter function if you don't want them to appear in your result. In your case, you should use NonEmtpy to eleminate the empty values.

Upvotes: 1

Related Questions