MONDRIAN MDX query for period of time

404 views Asked by At

I need to create an OLAP View just from one table in MySQL.

I need to get information from the following columns in my table: Date, Machine, Level, Item, Code, Comment, Downtime.

So I created this Mondrian Schema:

<Schema name="ExampleSchema">
 <Cube name="ExampleCube">
 <Table name="example_table"/>
    <Dimension name="Date">
        <Hierarchy hasAll="true" allMemberName="All Date">
            <Level name="Date" column="date" uniqueMembers="true"/>
        </Hierarchy>
    </Dimension>
    <Dimension name="Machine">
        <Hierarchy hasAll="true" allMemberName="All Machine">
            <Level name="Machine" column="machine" uniqueMembers="true"/>
        </Hierarchy>
    </Dimension>
    <Dimension name="Level">
        <Hierarchy hasAll="true" allMemberName="All Level">
            <Level name="Level" column="level" uniqueMembers="true"/>
        </Hierarchy>
    </Dimension>
    <Dimension name="Item">
        <Hierarchy hasAll="true" allMemberName="All Item">
            <Level name="Item" column="item" uniqueMembers="true"/>
        </Hierarchy>
    </Dimension>
    <Dimension name="Code">
        <Hierarchy hasAll="true" allMemberName="All Code">
            <Level name="Code" column="code" uniqueMembers="true"/>
        </Hierarchy>
    </Dimension>
    <Dimension name="Comment">
        <Hierarchy hasAll="true" allMemberName="All">
            <Level name="Comment" column="comment" uniqueMembers="true"/>
        </Hierarchy>
    </Dimension>
    <Measure name="Downtime" column="downtime" aggregator="sum" formatString="Standard" visible="true"/>
    </Cube>
    </Schema>

My query looks like follows:

{[Item].[All Item]} * {[Measures].[Downtime]}
ON columns,
{[Code].[All Code]} * {[Comment].[All Comment]}
ON rows
from [ExampleCube]
WHERE
{([Date].[2011-11-31], [Machine].[1500], [Level].[AB])}

It works, but I want to have measures not for a single date, but for a period of time (from the start date till the end date).

1

There are 1 answers

0
whytheq On

Try using the range operator :

{[Item].[All Item]} * {[Measures].[Downtime]}
ON columns,
{[Code].[All Code]} * {[Comment].[All Comment]}
ON rows
from [ExampleCube]
WHERE
(
{[Date].[2011-11-31]:[Date].[2015-06-25]}
, [Machine].[1500], [Level].[AB]
)

Both dates [Date].[2011-11-31]:[Date].[2015-06-25] must exist within your cube.