Snowflake dimension with multiple levels mondrian

848 views Asked by At

My tables structure is as follows

dim_question_tbl table with primary key dim_question_id_i(pk)

dim_grade_tbl -> dim_grade_id_i(pk), grade_name_c
dim_level_tbl -> dim_level_id_i(pk), level_name_c
dim_grade_question_tbl -> dim_grade_question_id_i(pk), dim_grade_id_i(fk), dim_level_id_i(fk)

Now i have to have the grade and level as the levels in dimension.

The cube written on the 'dim_question_tbl' table.

I have written the dimension as

<Dimension name="Grade" foreignKey="dim_question_id_i" highCardinality="false">
            <Hierarchy hasAll="true" primaryKey="dim_question_id_i" primaryKeyTable="dim_grade_question_tbl">               
                <join leftKey="dim_grade_id_i" rightKey="dim_grade_id_i">
                    <table name="dim_grade_question_tbl" />
                    <join leftKey="dim_level_id_i" rightKey="dim_level_id_i">
                        <table name="dim_grade_tbl" />
                        <table name="dim_level_tbl" />
                    </join>
                </join>
                <Level name="EnterpriseID" column="dim_enterprise_id_i" table="dim_grade_tbl" uniqueMembers="true" visible="false"/>
                <Level name="Grade" column="grade_name_c" table="dim_grade_tbl" uniqueMembers="true"/>
                <Level name="Level" column="level_name_c" table="dim_level_tbl" uniqueMembers="true"/>              
            </Hierarchy>
        </Dimension>

This does not working. The exception i am getting is '[Grade]' must have at least one level.

I have tried it with sql query also as

<Dimension name="Grade" foreignKey="dim_question_id_i" highCardinality="false">
            <Hierarchy hasAll="true" primaryKey="dim_question_id_i" primaryKeyTable="dim_grade_question_tbl">               
                <Query name="test">
                        <SQL dialect="generic">
                            SELECT *
                            FROM dim_grade_question_tbl, dim_grade_tbl, dim_level_tbl
                            WHERE dim_grade_question_tbl.dim_grade_id_i = dim_grade_tbl.dim_grade_id_i
                            and dim_grade_question_tbl.dim_level_id_i = dim_level_tbl.dim_level_id_i
                        </SQL>
                </Query>
                <Level name="Grade" column="grade_name_c" table="dim_grade_tbl" uniqueMembers="true"/>
                <Level name="Level" column="level_name_c" table="dim_level_tbl" uniqueMembers="true"/>              
            </Hierarchy>
        </Dimension>

With the sql query also the same exception i am getting.

Could any one help me how can i get the multiple levels with the snowflake schema?

0

There are 0 answers