Date range query with mondrian and olap4j

998 views Asked by At

I am using olap4j to query a mondrian cube. I have defined a standard TimeDimension in my schema xml:

    <Dimension name="DateTime" type="TimeDimension">
    <Hierarchy hasAll="true" primaryKey="DateId">
        <Table name="event_date" />
        <Level name="Year" column="Year" type="Numeric" uniqueMembers="true" levelType="TimeYears" />
        <Level name="Quarter" column="Quarter" captionColumn="QuarterLabel" uniqueMembers="false" levelType="TimeQuarters" />
        <Level name="Month" column="Month" captionColumn="MonthLabel" uniqueMembers="false" type="Numeric" levelType="TimeMonths" />
        <Level name="Week" column="Week" uniqueMembers="false" levelType="TimeWeeks" />
        <Level name="Day" column="Day" uniqueMembers="false" type="Numeric" levelType="TimeDays">
            <Property name="DayISO" column="DateIso" dependsOnLevelValue="true" />
            <Property name="DayOfWeek" column="DayOfWeek" dependsOnLevelValue="true" />
        </Level>
    </Hierarchy>
</Dimension>

What I cannot understand is how can I use olap4j to query a range of dates on cubes that have DateTime as a shared dimension.

Does anyone have any examples that can be shared?

Yosi

1

There are 1 answers

0
Luc On

In MDX, you can slice the results by a range of dates like so:

select
    (...)
where
    ([DateTime].[Month].[2] : [DateTime].[Month].[6])