在单个MDX查询中显示列名和ID

时间:2014-02-11 16:54:31

标签: mdx olap olap-cube

我有以下方面:

<Dimension type="StandardDimension" visible="true" foreignKey="ID_CATEGORIE" highCardinality="false" name="DIMENSION_CATEGORIE">
    <Hierarchy name="HIERARCHY_CATEGORIE" visible="true" hasAll="true" primaryKey="ID_CATEGORIE">
    <Table name="CATEGORIE_TICKET" schema="RAPPORT">
    </Table>
     <Level name="CATEGORIE" visible="true" table="CATEGORIE_TICKET" column="ID_CATEGORIE" nameColumn="CATEGORIE" type="String" uniqueMembers="true" levelType="Regular" hideMemberIf="Never">
    </Level>
    </Hierarchy>
</Dimension>  

MDX查询:

select {[Measures].[COUNT_TICKET]} ON COLUMNS,
  NON EMPTY {[DIMENSION_CATEGORIE.HIERARCHY_CATEGORIE].Children} ON ROWS
from [CUBE_TICKETS_DEPOSES]

返回以下数据:

                    Mesures
HIERARCHY_CATEGORIE COUNT_TICKET
Name1               20
Name2               30
...

问题:是否可以修改MDX查询以输出每个CATEGORIE列的ID,如下所示:

                                    Mesures
ID         HIERARCHY_CATEGORIE      COUNT_TICKET
id1        Name1                    20
id2        Name2                    30
...

我的CATEGORIE_TICKET表是:

  ID_CATEGORIE  CATEGORIE
  id1           Name1
  id2           Name2
  ....

1 个答案:

答案 0 :(得分:2)

找到它:

WITH
    MEMBER [Measures].[Key] AS
         [DIMENSION_CATEGORIE.HIERARCHY_CATEGORIE].CurrentMember.PROPERTIES("KEY")
select {[Measures].Members,  [Measures].[Key] } ON COLUMNS,
  {[DIMENSION_CATEGORIE.HIERARCHY_CATEGORIE].children}  ON ROWS
from [CUBE_TICKETS_DEPOSES]

给出了:

                               Mesures
HIERARCHY_CATEGORIE      COUNT_TICKET    KEY
Name1                    20              id1
Name2                    30              id2
...