我的做法是先在schema中定义好聚合表的相关值,如:<cube name="cube_agent_state" caption="test" encoding="UTF-8"> <Table name="fact_agent_status_fact"> <AggName name="agg_c_fact_agent_status_fact" > <AggFactCount column="fact_count"/> <AggForeignKey factColumn="time_id" aggColumn="time_id" /> <AggForeignKey factColumn="agent_no" aggColumn="agent_no" /> <AggForeignKey factColumn="agent_status" aggColumn="agent_status" /> <AggForeignKey factColumn="reason_code" aggColumn="reason_code" /> <AggMeasure name="[Measures].[times]" column="times"/> <AggMeasure name="[Measures].[length]" column="length"/> </AggName> </Table> <Dimension name="times" foreignKey="time_id" caption="时间"> <Hierarchy hasAll="true" primaryKey="time_id" > <Table name="dim_date" /> <Level name="year" column="y_id" uniqueMembers="false" type="String" levelType="TimeYears" c
maven项目:
pom文件
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>cn.firewarm</groupId>
<artifactId>testMondrian</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>testMondrian Maven Webapp</name>
<url>http://maven.apache.org</url>
<repositories>
<repository>
<id>mine</id>
<name>public Releases</name>
<layout>default</layout>
<url>http://nexus.liuyingguang.cn:8081/nexus/content/groups/public/</url>
</repository>
<repository>
<id>mine-meteorite-bi-release</id>
<name>pub
<?xml version="1.0" encoding="UTF-8" ?>
<Schema name="报表">
<cube name="cube_qc_pass_item" caption="报表1" encoding="UTF-8">
<table name="fact_qc_pass_record_item_join">
<Dimension name="models" foreignKey="model_id" caption="模板">
<Hierarchy hasAll="true" allMemberName="model_name" primaryKey="id" primaryKeyTable="dim_qc_model">
<Table name="dim_qc_model" />
<Level name="model_name" column="name" caption="模板"/>
<Level name="model_id" column="id" caption="model_id"/>
</Hierarchy>
</Dimension>
<Measure name="times" column="id" aggregator="count" formatString="#,###0" datatype="Numeric" caption="总量"/>
</cube>
</Schema>
我想要在使用mdx查询的时候,使用model_name显示,使用model_id作为查询条件限制某个model_id,该如何书写mdx语句?
SELECT
NON EMPTY {Hierarchize({{[Measures].[times], [Measures].[notPass], [Measures].[pass]}})}