Search code examples
mdxpentahomondrian

How can I return Level Property values in an MDX query?


I've defined a Dimension in a schema file containing multiple Levels. One of my Levels contains multiple properties, like:

<Level name="MyLevel" column="MyLevelColumn" nameColumn="MyLevelName">
    <Property name="Property1" column="PropertyColumn1"/>
    <Property name="Property2" column="PropertyColumn2"/>
    <Property name="Property3" column="PropertyColumn3"/>
    <Property name="Property4" column="PropertyColumn4"/>
</Level>

How can I return the values of these Properties, as well as the values of the measures I've defined in my Schema file?

Note: I don't want to use these filters to filter my results in the MDX query, so if there's a better way to get the data I want, please let me know! Thanks!


Solution

  • I don't know about Pentaho (couldn't find any MDX docs in a brief search of their site), but in SSAS, you can do the following:

    WITH
    MEMBER [Measures].[Property1] AS 
        ([MyDim].[MyLevel].CurrentMember.Properties("Property1"))
    SELECT
        {[Measures].[Property1], [Measures].[Amount]}
    ON COLUMNS,
        {[MyDim].[MyLevel].MEMBERS}
    ON ROWS
    FROM [Cube]