# [Mondrian] Problem Using Dimension Twice

Isaias Sanchez isaias.sanchez.l at gmail.com
Tue May 5 09:22:38 EDT 2015

```Ok, here we go:

1. Dimension "Destination Info" defined globally:

<Dimension name="Destination Info" table="destination"
key="Destination ID">
<Attributes>
<Attribute name="Destination ID" keyColumn="destination_id"
levelType="Regular" hasHierarchy="false"/>
<Attribute name="Destination Name"
keyColumn="destination_desc" levelType="Regular" hasHierarchy="false"/>
</Attributes>
<Hierarchies>
<Hierarchy name="Destination Info" hasAll="true">
<Level attribute="Destination Name"/>
</Hierarchy>
</Hierarchies>
</Dimension>

2. Dimension definition inside a cube:

<Dimension name="Destination Info - Internal" source="Destination Info" />
<Dimension name="Destination Info - Client" source="Destination Info" />
<Dimension name="Destination Info - Provider" source="Destination Info" />

3. Foreign key links:

<ForeignKeyLink  dimension="Destination Info - Internal"
foreignKeyColumn="internal_destination" />
<ForeignKeyLink  dimension="Destination Info - Client"
foreignKeyColumn="cli_destination" />
<ForeignKeyLink  dimension="Destination Info - Provider"
foreignKeyColumn="pro_destination" />

4. Successful MDX generated by Saiku:

WITH
SET [~FILTER] AS
{[Time].[Year by Weeks].[2015].[2015-05-04].[2015-05-05]}
SET [~COLUMNS] AS
{[Destination Info - Internal].[Destination Info].[ABKHAZIA]}
SET [~ROWS] AS
{[Destination Info - Client].[Destination Info].[Destination].Members}
SELECT
NON EMPTY CrossJoin([~COLUMNS], {[Measures].[Calls]}) ON COLUMNS,
NON EMPTY [~ROWS] ON ROWS
FROM [Traffic Management]
WHERE [~FILTER]

5. Failure MDX generated by Saiku:

WITH
SET [~FILTER] AS
{[Time].[Year by Weeks].[2015].[2015-05-04].[2015-05-05]}
SET [~ROWS_Destination Info] AS
{[Destination Info - Client].[Destination Info].[Destination].Members}
SET [~ROWS_Destination Info] AS
{[Destination Info - Internal].[Destination Info].[ABKHAZIA]}
SELECT
NON EMPTY {[Measures].[Calls]} ON COLUMNS,
NON EMPTY NonEmptyCrossJoin([~ROWS_Destination Info], [~ROWS_Destination
Info]) ON ROWS
FROM [Traffic Management]
WHERE [~FILTER]

Matt Campbell wrote on 05/05/15 14:53:
> I have a vague memory of there being an M4 issue similar to that, but couldn't find a logged bug.  Tried it out myself and added a role playing dimension for Time, then crossjoined Time and Time2.  That worked for me.
>
> Can you post the relevant schema snippets?
>
> -----Original Message-----
> From: mondrian-bounces at pentaho.org [mailto:mondrian-bounces at pentaho.org] On Behalf Of Isaias Sanchez
> Sent: Tuesday, May 05, 2015 8:40 AM
> To: mondrian at pentaho.org
> Subject: Re: [Mondrian] Problem Using Dimension Twice
>
> I am using Mondrian 4.0 (w/ saiku 3.1 standalone).
>
> And yes, I am using two dimensions using same source but different foreign keys into fact table.
>
> Exactly what's explained in the book Mondrian in Action, section 5.1.4.
>
> Matt Campbell wrote on 05/05/15 14:26:
>> What version of Mondrian are you running?  And do you mean you've added two DimensionUsages based off the same source?  Just tried a simple crossjoin of 2 usages of the Time dim w/ Foodmart using Mondrian 3.9, that worked for me.
>>
>>
>> -----Original Message-----
>> From: mondrian-bounces at pentaho.org
>> [mailto:mondrian-bounces at pentaho.org] On Behalf Of Isaias Sanchez
>> Sent: Tuesday, May 05, 2015 6:25 AM
>> To: Mondrian ML
>> Subject: [Mondrian] Problem Using Dimension Twice
>>
>> Hi,
>>
>> When I use a dimension twice (or more) in a cube, I can display one of them in rows and another in column, but I can't display both dimension together in Row field.
>>
>> I get this exception:
>> Caused by: mondrian.olap.MondrianException: Mondrian Error:Tuple contains more than one member of hierarchy ...
>>
>> I am just arriving to the list so probably you have talked about that before.
>>
>> Cheers,
>>
>> Isaias S.
>> _______________________________________________
>> Mondrian mailing list
>> Mondrian at pentaho.org
>> http://lists.pentaho.org/mailman/listinfo/mondrian
>> _______________________________________________
>> Mondrian mailing list
>> Mondrian at pentaho.org
>> http://lists.pentaho.org/mailman/listinfo/mondrian
>>
> _______________________________________________
> Mondrian mailing list
> Mondrian at pentaho.org
> http://lists.pentaho.org/mailman/listinfo/mondrian
> _______________________________________________
> Mondrian mailing list
> Mondrian at pentaho.org
> http://lists.pentaho.org/mailman/listinfo/mondrian
>

```