Performance issue with MDX query - mdx
I'm trying to get top 5 records from MySQL database based on some filters using below MDX query and cube definition.But, this query takes more time for execution and this works fine when we have less no.of FILE_NUM's in where condition. Please suggest how to rewrite this query to gain performance.
MDX Query:
SELECT {[Measures].[BBLSOIL_TOTAL], [Measures].[MCF_PROD_TOTAL],
[Measures].[AVG.DAYS]} ON COLUMNS,
{TOPCOUNT(FILTER([WELL_ID].[WellIds].MEMBERS, [WELL_ID].CurrentMember
0),5,[Measures].[BBLSOIL_TOTAL])} ON ROWS FROM [MON_KPI_CHARTS] WHERE({[Date].&[2015-09-01
00:00:00.0]}*{[FILE_NUM].[1],[FILE_NUM].[10],[FILE_NUM].[18],[FILE_NUM].[47],[FILE_NUM].[52],[FILE_NUM].[105],[FILE_NUM].[126],[FILE_NUM].[392],[FILE_NUM].[588],[FILE_NUM].[656],[FILE_NUM].[995],[FILE_NUM].[1005],[FILE_NUM].[1010],[FILE_NUM].[1061],[FILE_NUM].[1128],[FILE_NUM].[1137],[FILE_NUM].[1138],[FILE_NUM].[1337],[FILE_NUM].[1340],[FILE_NUM].[1410],[FILE_NUM].[1438],[FILE_NUM].[1503],[FILE_NUM].[1628],[FILE_NUM].[1698],[FILE_NUM].[1801],[FILE_NUM].[1808],[FILE_NUM].[1843],[FILE_NUM].[1876],[FILE_NUM].[1885],[FILE_NUM].[2017],[FILE_NUM].[2051],[FILE_NUM].[2053],[FILE_NUM].[2134],[FILE_NUM].[2929],[FILE_NUM].[2930],[FILE_NUM].[2931],[FILE_NUM].[2946],[FILE_NUM].[2979],[FILE_NUM].[3039],[FILE_NUM].[3080],[FILE_NUM].[3087],[FILE_NUM].[3124],[FILE_NUM].[3125],[FILE_NUM].[3165],[FILE_NUM].[3166],[FILE_NUM].[3237],[FILE_NUM].[3256],[FILE_NUM].[3314],[FILE_NUM].[3421],[FILE_NUM].[3445],[FILE_NUM].[3485],[FILE_NUM].[3493],[FILE_NUM].[3501],[FILE_NUM].[3552],[FILE_NUM].[3557],[FILE_NUM].[3622],[FILE_NUM].[3795],[FILE_NUM].[3812],[FILE_NUM].[3824],[FILE_NUM].[3837],[FILE_NUM].[3858],[FILE_NUM].[3884],[FILE_NUM].[3952],[FILE_NUM].[3963],[FILE_NUM].[3984],[FILE_NUM].[3995],[FILE_NUM].[4021],[FILE_NUM].[4030],[FILE_NUM].[4097],[FILE_NUM].[4117],[FILE_NUM].[4142],[FILE_NUM].[4145],[FILE_NUM].[4153],[FILE_NUM].[4155],[FILE_NUM].[4159],[FILE_NUM].[4161],[FILE_NUM].[4190],[FILE_NUM].[4209],[FILE_NUM].[4216],[FILE_NUM].[4223],[FILE_NUM].[4251],[FILE_NUM].[4255],[FILE_NUM].[4303],[FILE_NUM].[4313],[FILE_NUM].[4315],[FILE_NUM].[4329],[FILE_NUM].[4343],[FILE_NUM].[4346],[FILE_NUM].[4356],[FILE_NUM].[4366],[FILE_NUM].[4372],[FILE_NUM].[4400],[FILE_NUM].[4401],[FILE_NUM].[4409],[FILE_NUM].[4422],[FILE_NUM].[4443],[FILE_NUM].[4484],[FILE_NUM].[4501],[FILE_NUM].[4539],[FILE_NUM].[4569],[FILE_NUM].[4630],[FILE_NUM].[4638],[FILE_NUM].[4639],[FILE_NUM].[4658],[FILE_NUM].[4686],[FILE_NUM].[4698],[FILE_NUM].[4699],[FILE_NUM].[4768],[FILE_NUM].[4775],[FILE_NUM].[4794],[FILE_NUM].[4799],[FILE_NUM].[4803],[FILE_NUM].[4805],[FILE_NUM].[4835],[FILE_NUM].[4891],[FILE_NUM].[4923],[FILE_NUM].[4925],[FILE_NUM].[4929],[FILE_NUM].[4950],[FILE_NUM].[4956],[FILE_NUM].[4961],[FILE_NUM].[4978],[FILE_NUM].[4987],[FILE_NUM].[4990],[FILE_NUM].[4992],[FILE_NUM].[4996],[FILE_NUM].[5020],[FILE_NUM].[5025],[FILE_NUM].[5026],[FILE_NUM].[5048],[FILE_NUM].[5057],[FILE_NUM].[5058],[FILE_NUM].[5067],[FILE_NUM].[5074],[FILE_NUM].[5075],[FILE_NUM].[5077],[FILE_NUM].[5079],[FILE_NUM].[5080],[FILE_NUM].[5090],[FILE_NUM].[5095],[FILE_NUM].[5096],[FILE_NUM].[5098],[FILE_NUM].[5103],[FILE_NUM].[5105],[FILE_NUM].[5139],[FILE_NUM].[5149],[FILE_NUM].[5154],[FILE_NUM].[5158],[FILE_NUM].[5165],[FILE_NUM].[5180],[FILE_NUM].[5198],[FILE_NUM].[5199],[FILE_NUM].[5207],[FILE_NUM].[5215],[FILE_NUM].[5219],[FILE_NUM].[5223],[FILE_NUM].[5236],[FILE_NUM].[5242],[FILE_NUM].[5275],[FILE_NUM].[5300],[FILE_NUM].[5304],[FILE_NUM].[5313],[FILE_NUM].[5321],[FILE_NUM].[5356],[FILE_NUM].[5368],[FILE_NUM].[5389],[FILE_NUM].[5401],[FILE_NUM].[5444],[FILE_NUM].[5457],[FILE_NUM].[5467],[FILE_NUM].[5468],[FILE_NUM].[5498],[FILE_NUM].[5519],[FILE_NUM].[5520],[FILE_NUM].[5531],[FILE_NUM].[5539],[FILE_NUM].[5542],[FILE_NUM].[5563],[FILE_NUM].[5578],[FILE_NUM].[5707],[FILE_NUM].[5723],[FILE_NUM].[5761],[FILE_NUM].[5785],[FILE_NUM].[5795],[FILE_NUM].[5809],[FILE_NUM].[5830],[FILE_NUM].[5860],[FILE_NUM].[5903],[FILE_NUM].[5923],[FILE_NUM].[5962],[FILE_NUM].[5966],[FILE_NUM].[5970],[FILE_NUM].[5996],[FILE_NUM].[6005],[FILE_NUM].[6006],[FILE_NUM].[6008],[FILE_NUM].[6012],[FILE_NUM].[6023],[FILE_NUM].[6032],[FILE_NUM].[6041],[FILE_NUM].[6043],[FILE_NUM].[6073],[FILE_NUM].[6100],[FILE_NUM].[6150],[FILE_NUM].[6201],[FILE_NUM].[6223],[FILE_NUM].[6271],[FILE_NUM].[6295],[FILE_NUM].[6314],[FILE_NUM].[6404],[FILE_NUM].[6440],[FILE_NUM].[6459],[FILE_NUM].[6482],[FILE_NUM].[6486],[FILE_NUM].[6502],[FILE_NUM].[6540],[FILE_NUM].[6588],[FILE_NUM].[6610],[FILE_NUM].[6637],[FILE_NUM].[6653],[FILE_NUM].[6664],[FILE_NUM].[6725],[FILE_NUM].[6819],[FILE_NUM].[6871],[FILE_NUM].[6932],[FILE_NUM].[6934],[FILE_NUM].[6978],[FILE_NUM].[7009],[FILE_NUM].[7042],[FILE_NUM].[7043],[FILE_NUM].[7055],[FILE_NUM].[7493],[FILE_NUM].[7547],[FILE_NUM].[7554],[FILE_NUM].[7612],[FILE_NUM].[7624],[FILE_NUM].[7638],[FILE_NUM].[7646],[FILE_NUM].[7671],[FILE_NUM].[7693],[FILE_NUM].[7695],[FILE_NUM].[7696],[FILE_NUM].[7697],[FILE_NUM].[7698],[FILE_NUM].[7708],[FILE_NUM].[7710],[FILE_NUM].[7711],[FILE_NUM].[7862],[FILE_NUM].[7910],[FILE_NUM].[7927],[FILE_NUM].[7960],[FILE_NUM].[7962],[FILE_NUM].[8009],[FILE_NUM].[8033],[FILE_NUM].[8056],[FILE_NUM].[8057],[FILE_NUM].[8104],[FILE_NUM].[8109],[FILE_NUM].[8170],[FILE_NUM].[8177],[FILE_NUM].[8181],[FILE_NUM].[8211],[FILE_NUM].[8323],[FILE_NUM].[8376],[FILE_NUM].[8412],[FILE_NUM].[8475],[FILE_NUM].[8541],[FILE_NUM].[8547],[FILE_NUM].[8578],[FILE_NUM].[8654],[FILE_NUM].[8691],[FILE_NUM].[8697],[FILE_NUM].[8699],[FILE_NUM].[8749],[FILE_NUM].[8763],[FILE_NUM].[8790],[FILE_NUM].[8840],[FILE_NUM].[8870],[FILE_NUM].[8939],[FILE_NUM].[9036],[FILE_NUM].[9077],[FILE_NUM].[9094],[FILE_NUM].[9107],[FILE_NUM].[9149],[FILE_NUM].[9150],[FILE_NUM].[9293],[FILE_NUM].[9429],[FILE_NUM].[9499],[FILE_NUM].[9550],[FILE_NUM].[9571],[FILE_NUM].[9579],[FILE_NUM].[9752],[FILE_NUM].[9910],[FILE_NUM].[9953],[FILE_NUM].[10270],[FILE_NUM].[10271],[FILE_NUM].[10272],[FILE_NUM].[10273],[FILE_NUM].[10274],[FILE_NUM].[10275],[FILE_NUM].[10309],[FILE_NUM].[10326],[FILE_NUM].[10403],[FILE_NUM].[10408],[FILE_NUM].[10471],[FILE_NUM].[10491],[FILE_NUM].[10496],[FILE_NUM].[10505],[FILE_NUM].[10551],[FILE_NUM].[10572],[FILE_NUM].[10601],[FILE_NUM].[10615],[FILE_NUM].[10679],[FILE_NUM].[10725],[FILE_NUM].[10778],[FILE_NUM].[10819],[FILE_NUM].[11002],[FILE_NUM].[11042],[FILE_NUM].[11055],[FILE_NUM].[11076],[FILE_NUM].[11095],[FILE_NUM].[11112],[FILE_NUM].[11213],[FILE_NUM].[11249],[FILE_NUM].[11308],[FILE_NUM].[11311],[FILE_NUM].[11486],[FILE_NUM].[11555]})
Cube Definition:
<Schema name="ONG" description="Schema for RIAB">
<Dimension type="StandardDimension" visible="true" highCardinality="false" name="Location">
<Hierarchy name="LOCATION_HIR" visible="true" hasAll="true" allMemberName="AllLocations" primaryKey="FILE_NO">
<Table name="mas_well_spatial_dim">
</Table>
<Level name="Township" visible="true" column="TOWNSHIP" type="String" uniqueMembers="true" levelType="Regular" hideMemberIf="Never">
</Level>
<Level name="Range" visible="true" column="RANGE" type="String" uniqueMembers="true" levelType="Regular" hideMemberIf="Never">
</Level>
<Level name="Section" visible="true" column="SECTION" type="String" uniqueMembers="true" levelType="Regular" hideMemberIf="Never">
</Level>
<Level name="CountyName" visible="true" column="COUNTY_NAME" type="String" uniqueMembers="true" levelType="Regular" hideMemberIf="Never">
</Level>
<Level name="FieldName" visible="true" column="FIELD_NAME" type="String" uniqueMembers="true" levelType="Regular" hideMemberIf="Never">
</Level>
</Hierarchy>
</Dimension>
<Dimension type="StandardDimension" visible="true" highCardinality="false" name="WellIndex">
<Hierarchy name="WellIndex_HIR" visible="true" hasAll="true" allMemberName="AllWellIndexes" primaryKey="FILE_NO">
<Table name="mas_well_index">
</Table>
<Level name="Wellbore" visible="true" column="WELL_BORE" type="String" uniqueMembers="true" levelType="Regular" hideMemberIf="Never">
</Level>
<Level name="TotalDepth" visible="true" column="TOTAL_DEPTH" type="Integer" internalType="int" uniqueMembers="true" levelType="Regular" hideMemberIf="Never">
</Level>
<Level name="CurrentOperator" visible="true" column="CURRENT_OPERATOR" type="String" internalType="String" uniqueMembers="true" levelType="Regular" hideMemberIf="Never">
</Level>
<Level name="OriginalOperator" visible="true" column="ORIGINAL_OPERATOR" type="String" internalType="String" uniqueMembers="true" levelType="Regular" hideMemberIf="Never">
</Level>
<Level name="SpudDate" visible="true" column="SPUD_DATE" type="Date" uniqueMembers="true" levelType="Regular" hideMemberIf="Never">
</Level>
<Level name="WellStatus" visible="true" column="WELL_STATUS" type="String" internalType="String" uniqueMembers="true" levelType="Regular" hideMemberIf="Never">
</Level>
<Level name="WellType" visible="true" column="WELL_TYPE" type="String" internalType="String" uniqueMembers="true" levelType="Regular" hideMemberIf="Never">
</Level>
</Hierarchy>
</Dimension>
<Dimension type="StandardDimension" visible="true" name="FIELD_NAME">
<Hierarchy name="FIELD_NAME_HIR" visible="true" hasAll="true" allMemberName="AllFieldNames" primaryKey="FILE_NO">
<Table name="mas_well_spatial_dim">
</Table>
<Level name="FIELD_NAME" visible="true" column="FIELD_NAME" type="String" internalType="String" uniqueMembers="true" levelType="Regular" hideMemberIf="Never">
</Level>
</Hierarchy>
</Dimension>
<Dimension type="StandardDimension" visible="true" highCardinality="false" name="FILE_NUM">
<Hierarchy name="FILE_NUM_HIR" visible="true" hasAll="true" allMemberName="AllFileNos" primaryKey="FILE_NO">
<Table name="mas_well_index">
</Table>
<Level name="FileNos" visible="true" column="FILE_NO" type="Numeric" uniqueMembers="true" levelType="Regular" hideMemberIf="Never">
</Level>
</Hierarchy>
</Dimension>
<Cube name="MON_KPI_CHARTS" visible="true" cache="true" enabled="true">
<Table name="prd_well_production_monthly">
</Table>
<Dimension type="TimeDimension" visible="true" foreignKey="DATE_ID" highCardinality="false" name="TIME">
<Hierarchy name="Quaterly" visible="true" hasAll="true" primaryKey="DATE_ID">
<Table name="mas_date_temporal_dim">
</Table>
<Level name="Year" visible="true" table="mas_date_temporal_dim" column="YEAR" type="Integer" uniqueMembers="true" levelType="TimeYears" hideMemberIf="Never">
</Level>
<Level name="Quarter" visible="true" table="mas_date_temporal_dim" column="QUARTER" type="String" uniqueMembers="false" levelType="TimeQuarters" hideMemberIf="Never">
</Level>
<Level name="Month" visible="true" table="mas_date_temporal_dim" column="MONTH" type="String" uniqueMembers="false" levelType="TimeMonths" hideMemberIf="Never">
</Level>
</Hierarchy>
<Hierarchy name="Monthly" visible="true" hasAll="true" primaryKey="DATE_ID">
<Table name="mas_date_temporal_dim">
</Table>
<Level name="Year" visible="true" table="mas_date_temporal_dim" column="YEAR" type="Integer" uniqueMembers="true" levelType="TimeYears" hideMemberIf="Never">
</Level>
<Level name="Month" visible="true" table="mas_date_temporal_dim" column="MONTH" type="String" uniqueMembers="false" levelType="TimeMonths" hideMemberIf="Never">
</Level>
<Level name="Day" visible="true" table="mas_date_temporal_dim" column="DAY" type="Integer" uniqueMembers="false" levelType="TimeDays" hideMemberIf="Never">
</Level>
</Hierarchy>
</Dimension>
<Dimension type="StandardDimension" visible="true" foreignKey="FILE_NO" highCardinality="false" name="WELL_ID">
<Hierarchy name="WELL_ID_HIR" visible="true" hasAll="true" allMemberName="AllWells" primaryKey="FILE_NO">
<Table name="mas_well_index">
</Table>
<Level name="WellIds" visible="true" column="API_NO" type="Numeric" uniqueMembers="true" levelType="Regular" hideMemberIf="Never">
</Level>
</Hierarchy>
</Dimension>
<Dimension type="StandardDimension" visible="true" foreignKey="FILE_NO" highCardinality="false" name="CURRENT_OPTR">
<Hierarchy name="CURRENT_OPTR_HIR" visible="true" hasAll="true" allMemberName="AllWells" primaryKey="FILE_NO">
<Table name="mas_well_index">
</Table>
<Level name="CurrentOperator" visible="true" column="CURRENT_OPERATOR" type="String" internalType="String" uniqueMembers="true" levelType="Regular" hideMemberIf="Never">
</Level>
</Hierarchy>
</Dimension>
<DimensionUsage source="FILE_NUM" name="FILE_NUM" visible="true" foreignKey="FILE_NO">
</DimensionUsage>
<DimensionUsage source="Location" name="LOCATION" visible="true" foreignKey="FILE_NO" highCardinality="false">
</DimensionUsage>
<DimensionUsage source="WellIndex" name="WELL_INDEX" visible="true" foreignKey="FILE_NO" highCardinality="false">
</DimensionUsage>
<Dimension type="StandardDimension" visible="true" foreignKey="DATE_ID" highCardinality="false" name="MON_KPI_DATE">
<Hierarchy name="DATE_HIR" visible="true" hasAll="true" allMemberName="AllDateValues" primaryKey="DATE_ID">
<Table name="mas_date_temporal_dim">
</Table>
<Level name="DATE" visible="true" table="mas_date_temporal_dim" column="DATE_VALUE" type="String" uniqueMembers="true" levelType="Regular" hideMemberIf="Never">
</Level>
</Hierarchy>
</Dimension>
<Dimension type="StandardDimension" visible="true" highCardinality="false" name="DATE_VALUE">
<Hierarchy name="DATE_VALUE_HIR" visible="true" hasAll="true" allMemberName="AllDateValues" primaryKey="FILE_NO">
<Level name="DATE" visible="true" column="DATE" type="Timestamp" uniqueMembers="true" levelType="Regular" hideMemberIf="Never">
</Level>
</Hierarchy>
</Dimension>
<Dimension type="StandardDimension" visible="true" foreignKey="FILE_NO" highCardinality="false" name="COUNTY">
<Hierarchy name="COUNTY_HIR" visible="true" hasAll="true" allMemberName="AllCounties" primaryKey="FILE_NO">
<Table name="mas_well_spatial_dim">
</Table>
<Level name="CountyName" visible="true" column="COUNTY_NAME" type="String" uniqueMembers="true" levelType="Regular" hideMemberIf="Never">
</Level>
</Hierarchy>
</Dimension>
<DimensionUsage source="FIELD_NAME" name="FIELDNAME" visible="true" foreignKey="FILE_NO">
</DimensionUsage>
<Measure name="BBLSOIL_TOTAL" column="OIL_PROD_BBLS" datatype="Numeric" formatString="Standard" aggregator="sum" visible="true">
</Measure>
<Measure name="VENT_FLARE_TOTAL" column="GAS_VENT_MCF" datatype="Numeric" formatString="Standard" aggregator="sum" visible="true">
</Measure>
<Measure name="BBLSWATER_TOTAL" column="WATER_PROD_BBLS" datatype="Numeric" formatString="Standard" aggregator="sum" visible="true">
</Measure>
<Measure name="MCF_PROD_TOTAL" column="GAS_PROD_MCF" datatype="Numeric" formatString="Standard" aggregator="sum" visible="true">
</Measure>
<Measure name="AVG.DAYS" column="DAYS_IN_PROD" datatype="Numeric" formatString="###.####" aggregator="avg" visible="true">
</Measure>
</Cube>
<Cube name="SPUD_KPI_CHART" visible="true" cache="true" enabled="true">
<Table name="mas_well_spatial_dim">
</Table>
<Dimension type="StandardDimension" visible="true" foreignKey="FILE_NO" highCardinality="false" name="WELL_ID">
<Hierarchy name="WELL_ID_HIR" visible="true" hasAll="true" allMemberName="AllWellIDs" primaryKey="FILE_NO">
<Table name="mas_well_index">
</Table>
<Level name="WellIDs" visible="true" column="API_NO" type="Numeric" uniqueMembers="true" levelType="Regular" hideMemberIf="Never">
</Level>
</Hierarchy>
</Dimension>
<DimensionUsage source="FILE_NUM" name="FILE_NUM" visible="true" foreignKey="FILE_NO">
</DimensionUsage>
<DimensionUsage source="FIELD_NAME" name="FIELDNAME" visible="true" foreignKey="FILE_NO">
</DimensionUsage>
<Dimension type="StandardDimension" visible="true" foreignKey="FILE_NO" name="SPUDDATE">
<Hierarchy name="SPUDDATE_HIR" visible="true" hasAll="true" allMemberName="AllDates" primaryKey="FILE_NO">
<Table name="mas_well_index">
</Table>
<Level name="SPUD_DATE" visible="true" column="SPUD_DATE" type="String" uniqueMembers="true" levelType="Regular" hideMemberIf="Never">
</Level>
</Hierarchy>
</Dimension>
<Measure name="NewWells" column="FIELD_NAME" datatype="Integer" formatString="Standard" aggregator="count" visible="true">
</Measure>
</Cube>
</Schema>
Since Mondrian is a ROLAP engine ultimately the MDX getting converted in to SQL and that SQL runs on the DB. So all RDBMS factors like number of rows, table size and indexes are matters for performance. You may enable the Mondiran SQL logs at WEB-INF/classes/log4j.xml and see the corresponding SQL. You may have to do some optimisations to DB as well.
Related
Mondrian MDX Query error:- All arguments to function '{}' must have same hierarchy
I am using Tibco Jaspersoft to generate the report. Expected result:- Created Schema File: <Schema name="Telemetry Count Schema"> <Cube name="Telemetry Count Cube" cache="true" enabled="true"> <Table name="device_telementry"> </Table> <Dimension type="StandardDimension" foreignKey="companyId" name="Tenant"> <Hierarchy hasAll="true" allMemberName="All Tenant" primaryKey="id"> <Table name="device"> </Table> <Level name="Tenant Level " column="name" type="String" uniqueMembers="true" levelType="Regular" hideMemberIf="Never"> </Level> </Hierarchy> </Dimension> <Dimension type="StandardDimension" foreignKey="subscriptionId" name="Subscription"> <Hierarchy hasAll="true" allMemberName="All Subscription" primaryKey="id"> <Table name="subscription"> </Table> <Level name="Subscription Level" column="name" type="String" uniqueMembers="true" levelType="Regular" hideMemberIf="Never"> </Level> </Hierarchy> </Dimension> <Dimension type="StandardDimension" foreignKey="applicationId" name="Application"> <Hierarchy hasAll="true" allMemberName="All Application" primaryKey="id"> <Table name="application"> </Table> <Level name="Application Level" column="name" type="String" uniqueMembers="true" levelType="Regular" hideMemberIf="Never"> </Level> </Hierarchy> </Dimension> <Dimension type="StandardDimension" foreignKey="gatewayId" name="Gateway"> <Hierarchy hasAll="true" allMemberName="All Gateway" primaryKey="id"> <Table name="gateway"> </Table> <Level name="Gateway Level" column="name" type="String" uniqueMembers="true" levelType="Regular" hideMemberIf="Never"> </Level> </Hierarchy> </Dimension> <Dimension type="StandardDimension" foreignKey="deviceId" name="Device"> <Hierarchy hasAll="true" allMemberName="All Device" primaryKey="id"> <Table name="device"> </Table> <Level name="Device Level" column="name" type="String" uniqueMembers="true" levelType="Regular" hideMemberIf="Never"> </Level> </Hierarchy> </Dimension> <Measure name="Telemetry Count" column="telemetry_count" aggregator="sum" visible="true"> </Measure> <Measure name="Telemetry Item Count" column="telemetry_item_count" aggregator="count" visible="true"> </Measure> </Cube> </Schema> MDX Query:- select {[Measures].[Telemetry Count], [Measures].[Telemetry Item Count]} ON COLUMNS, {[Gateway].[All Gateway], [Gateway].[All Gateway].Children, [Device].[All Device], [Device].[All Device].Children} ON ROWS from [Telemetry Count Cube] Error Message: Mondrian Error: All arguments to function '{}' must have same hierarchy. What am I doing wrong here?
Resultant MDX Query:- select {[Measures].[Telemetry Count], [Measures].[Telemetry Item Count]} ON COLUMNS, NON EMPTY { CrossJoin ( {([Application].members)}, {CrossJoin ( {([Gateway].members)}, {([Device].members)} ) }) } ON ROWS from [Telemetry Count Cube]
Empty cells/offset in the report: how to define a dimension and hierarchy in the cube?
I want to analyze some dynamics of the some process. For that I use Saiku analytics plugin CE for Pentaho Business Intelligence Server CE 5.0.1. There is a table of facts and a table of dimensions that using to perform some aggregations. Dimensions represent the hierarchy "Year - Month - Day". I built some report in two cuts - by year and months. Report looks as follows: The data it shows is correct: If I define an independent dimension "Month", the report is looks right: However, the data already is not right: I tried to add the inverse dimension "Month - Year", but did not see any data. Is there a way to define a dimension, where the report will not include empty cells?
I found the solution - the problem was in the wrong dimension of date. See detailed answer here: Create a date range in mysql New Mondrian schema: <Schema name="MondrianSchema"> <Dimension type="TimeDimension" visible="true" highCardinality="false" name="X dimension"> <Hierarchy name="X_hierarchy" visible="true" hasAll="true" primaryKey="date_key"> <Table name="tbl_declaration_date_dim" schema="dbo"> </Table> <Level name="Year" visible="true" table="tbl_declaration_date_dim" column="Year" nameColumn="Year" type="Numeric" uniqueMembers="true" levelType="TimeYears" hideMemberIf="Never"> </Level> <Level name="Month" visible="true" table="tbl_declaration_date_dim" column="Month" nameColumn="Month" ordinalColumn="Month" type="Numeric" uniqueMembers="false" levelType="TimeMonths" hideMemberIf="Never"> </Level> <Level name="Day" visible="true" table="tbl_declaration_date_dim" column="Day" nameColumn="Day" ordinalColumn="Day" type="Numeric" uniqueMembers="false" levelType="TimeDays" hideMemberIf="Never"> </Level> </Hierarchy> </Dimension> <Dimension type="TimeDimension" visible="true" name="Y dimension"> <Hierarchy name="Y_Hierarchy" visible="true" hasAll="true" primaryKey="date_key"> <Table name="tbl_declaration_date_dim" schema="dbo" alias=""> </Table> <Level name="Year" visible="true" table="tbl_declaration_date_dim" column="Year" nameColumn="Year" type="Numeric" uniqueMembers="true" levelType="TimeYears" hideMemberIf="Never"> </Level> <Level name="Month" visible="true" table="tbl_declaration_date_dim" column="Month" nameColumn="Month" ordinalColumn="Month" type="Numeric" uniqueMembers="false" levelType="TimeMonths" hideMemberIf="Never"> </Level> <Level name="Day" visible="true" table="tbl_declaration_date_dim" column="Day" nameColumn="Day" ordinalColumn="Day" type="Numeric" uniqueMembers="false" levelType="TimeDays" hideMemberIf="Never"> </Level> </Hierarchy> </Dimension> <Cube name="tbl_application_cube" caption="..." visible="true" description="..." cache="true" enabled="true"> <Table name="tbl_appl_olap_fact" schema="dbo"> </Table> <DimensionUsage source="X dimension" name="X axis" visible="true" foreignKey="date_dim" highCardinality="false"> </DimensionUsage> <DimensionUsage source="Y dimension" name="Y axis" visible="true" foreignKey="date_dim"> </DimensionUsage> <Measure name="DeclarationCount" column="declaration_id" aggregator="count" visible="true"> </Measure> </Cube> </Schema>
MDX query takes forever to run in jPivot
I am working on a BI project. I am using mondian olap server and jPivot. I am using star model in schema file. The mdx query takes forever to run when I click on the last plus button for drilldown (coming from the right). In the DB there are only around 5000 records. I am using oracle database. The first mdx query is SELECT NON EMPTY {[Measures].[Revenue]} ON COLUMNS, NON EMPTY ({([Stream].[All Stream],[Portfolio].[All Portfolio],[Serviceline].[All Serviceline], [Year].[All Year], [Month].[All Month], [Department].[All Department])}) ON ROWS FROM [RevenueBudget] WHERE ([Time].[201404] : [Time].[201508]) I have tried executing the query(fourth level) in schema work bench. It hardly takes 40 sec. to execute. I have also checked the background sql queries using java profiler. But its well around one min. So why it is taking so long for jpivot to display the records, if I am right its the problem of jpivot. Any help is highly expected. The fourth level MDX query got from JPivot MDX editor is below select NON EMPTY {[Measures].[Revenue]} ON COLUMNS, NON EMPTY Hierarchize(Crossjoin({[Stream].[All Stream]}, Union(Crossjoin({[Portfolio].[All Portfolio]}, Union(Crossjoin({[Serviceline].[All Serviceline]}, Union(Crossjoin({[Year].[All Year]}, Union(Crossjoin({[Month].[All Month]}, {[Department].[All Department]}), Crossjoin({[Month].[All Month]}, [Department].[All Department].Children))), Crossjoin({[Year].[All Year]}, Union(Crossjoin([Month].[All Month].Children, {[Department].[All Department]}), Crossjoin([Month].[All Month].Children, [Department].[All Department].Children))))), Crossjoin({[Serviceline].[All Serviceline]}, Union(Crossjoin([Year].[All Year].Children, Union(Crossjoin({[Month].[All Month]}, {[Department].[All Department]}), Crossjoin({[Month].[All Month]}, [Department].[All Department].Children))), Crossjoin([Year].[All Year].Children, Union(Crossjoin([Month].[All Month].Children, {[Department].[All Department]}), Crossjoin([Month].[All Month].Children, [Department].[All Department].Children))))))), Crossjoin({[Portfolio].[All Portfolio]}, Union(Crossjoin([Serviceline].[All Serviceline].Children, Union(Crossjoin({[Year].[All Year]}, Union(Crossjoin({[Month].[All Month]}, {[Department].[All Department]}), Crossjoin({[Month].[All Month]}, [Department].[All Department].Children))), Crossjoin({[Year].[All Year]}, Union(Crossjoin([Month].[All Month].Children, {[Department].[All Department]}), Crossjoin([Month].[All Month].Children, [Department].[All Department].Children))))), Crossjoin([Serviceline].[All Serviceline].Children, Union(Crossjoin([Year].[All Year].Children, Union(Crossjoin({[Month].[All Month]}, {[Department].[All Department]}), Crossjoin({[Month].[All Month]}, [Department].[All Department].Children))), Crossjoin([Year].[All Year].Children, Union(Crossjoin([Month].[All Month].Children, {[Department].[All Department]}), Crossjoin([Month].[All Month].Children, [Department].[All Department].Children)))))))))) ON ROWS from [RevenueBudget] where ([Time].[201304] : [Time].[201508]) The schema XML file is <Schema name="RevenueBudget"> <Cube name="RevenueBudget" cache="true" enabled="true"> <Table name="MVW_DIMENSION_TRANSACTIONS"> </Table> <Dimension name="Time" type="TimeDimension" foreignKey="DIMENSION_TRANSACTION_ID"> <Hierarchy hasAll="false" primaryKey="DIMENSION_TRANSACTION_ID"> <Table name="MVW_DIMENSION_TRANSACTIONS"/> <Level name="YEAR_MONTH" column="YEAR_MONTH" type="Numeric" uniqueMembers="false" levelType="TimeYears"/> </Hierarchy> </Dimension> <Dimension type="StandardDimension" foreignKey="STREAM_MASTER_ID" name="Stream"> <Hierarchy allMemberName="All Stream" defaultMember="All Stream" hasAll="true" primaryKey="STREAM_MASTER_ID"> <Table name="MVW_STREAM_MASTERS"> </Table> <Level name="StrName" column="STREAM_DESCRIPTION" keyColumn="STREAM_MASTER_ID" nameColumn="STREAM_DESCRIPTION" type="String" uniqueMembers="false" levelType="Regular" hideMemberIf="Never"> </Level> </Hierarchy> </Dimension> <Dimension type="StandardDimension" foreignKey="PORTFOLIO_MASTER_ID" name="Portfolio"> <Hierarchy allMemberName="All Portfolio" defaultMember="All Portfolio" hasAll="true" primaryKey="PORTFOLIO_MASTER_ID"> <Table name="MVW_PORTFOLIO_MASTERS"> </Table> <Level name="PortfolioName" column="PORTFOLIO_DESCRIPTION" keyColumn="PORTFOLIO_MASTER_ID" nameColumn="PORTFOLIO_DESCRIPTION" type="String" uniqueMembers="false" levelType="Regular" hideMemberIf="Never"> </Level> </Hierarchy> </Dimension> <Dimension type="StandardDimension" foreignKey="SERVICELINE_MASTER_ID" name="Serviceline"> <Hierarchy allMemberName="All Serviceline" defaultMember="All Serviceline" hasAll="true" primaryKey="SERVICELINE_MASTER_ID"> <Table name="MVW_SERVICELINE_MASTERS"> </Table> <Level name="ServicelineName" column="SERVICELINE_DESCRIPTION" keyColumn="SERVICELINE_MASTER_ID" nameColumn="SERVICELINE_DESCRIPTION" type="String" uniqueMembers="false" levelType="Regular" hideMemberIf="Never"> </Level> </Hierarchy> </Dimension> <Dimension type="StandardDimension" foreignKey="YEAR_ID" name="Year"> <Hierarchy allMemberName="All Year" defaultMember="All Year" hasAll="true" primaryKey="YEAR_ID"> <Table name="MVW_YEAR"></Table> <Level name="YearId" column="YEAR" keyColumn="YEAR_ID" nameColumn="YEAR" type="String" uniqueMembers="false" levelType="Regular" hideMemberIf="Never"> </Level> </Hierarchy> </Dimension> <Dimension type="StandardDimension" foreignKey="MONTH_ID" name="Month"> <Hierarchy allMemberName="All Month" defaultMember="All Month" hasAll="true" primaryKey="MONTH_ID"> <Table name="MVW_MONTH"> </Table> <Level name="MonthName" column="MONTH" keyColumn="MONTH_ID" nameColumn="MONTH" type="String" uniqueMembers="false" levelType="Regular" hideMemberIf="Never"> </Level> </Hierarchy> </Dimension> <Dimension type="StandardDimension" foreignKey="DEPARTMENT_MASTER_ID" name="Department"> <Hierarchy allMemberName="All Department" defaultMember="All Department" hasAll="true" primaryKey="DEPARTMENT_MASTER_ID"> <Table name="MVW_DEPARTMENT_MASTERS"> </Table> <Level name="DepartmentName" column="DEPARTMENT_DESCRIPTION" keyColumn="DEPARTMENT_MASTER_ID" nameColumn="DEPARTMENT_DESCRIPTION" type="String" uniqueMembers="false" levelType="Regular" hideMemberIf="Never"> </Level> </Hierarchy> </Dimension> <Measure name="Revenue" column="REVENUE_AMOUNT" datatype="Numeric" aggregator="sum" visible="true"></Measure> </Cube> </Schema>
I wonder if moving the set to the WITH clause helps? WITH SET [TargetSet] AS [Stream].[All Stream]* [Portfolio].[All Portfolio]* [Serviceline].[All Serviceline]* [Year].[All Year]* [Month].[All Month]* [Department].[All Department] SELECT NON EMPTY {[Measures].[Revenue]} ON COLUMNS ,NON EMPTY [TargetSet] ON ROWS FROM [RevenueBudget] WHERE [Time].[201404] : [Time].[201508];
Querying only dimension in a cube using MDX
I have a cube with one fact table and four dimensions (Date, Product, Shop and Country). Dimensions are connected to fact using primary-foreign keys as usual. I want to query this model for getting only dimensional information (i.e I don't need any fact table columns). For example, I want to see the status (ACTIVE/INACTIVE etc) all shops in all countries. The query I have written is WITH MEMBER [Dim shop.Shop id].[Shop count] AS Count([Dim shop.Shop id].Members, EXCLUDEEMPTY) --select the count of shop members SET [~ROWS_Dim country.Country name] AS {[Dim country.Country name].[Country name].Members} --All countries SET [~ROWS_Dim shop.Status] AS {[Dim shop.Status].[Status].Members} --All shop statuses SELECT NON EMPTY [Dim shop.Shop id].[Shop count] ON COLUMNS, NON EMPTY NonEmptyCrossJoin([~ROWS_Dim country.Country name], [~ROWS_Dim shop.Status]) ON ROWS FROM [cube] WHERE ({[Dim shop.Date to].[2199-12-31 22:59:59.999],[Dim shop.Date to].[2199-12-31 23:59:59.999]}) --Slicing to get only currently inventoried shops The schema looks like below <Schema name="cube"> <Dimension name="Dim country"> <Hierarchy name="Cid" hasAll="true" primaryKey="cid"> <Table name="dim_country" schema="dw_pp"/> <Level name="Cid" uniqueMembers="false" column="cid" type="Numeric"> </Level> </Hierarchy> <Hierarchy name="Country code name" hasAll="true" primaryKey="cid"> <Table name="dim_country" schema="dw_pp"/> <Level name="Country code name" uniqueMembers="false" column="country_code_name" type="String"> </Level> </Hierarchy> <Hierarchy name="Country currency" hasAll="true" primaryKey="cid"> <Table name="dim_country" schema="dw_pp"/> <Level name="Country currency" uniqueMembers="false" column="country_currency" type="String"> </Level> </Hierarchy> <Hierarchy name="Country ga id" hasAll="true" primaryKey="cid"> <Table name="dim_country" schema="dw_pp"/> <Level name="Country ga id" uniqueMembers="false" column="country_ga_id" type="Numeric"> </Level> </Hierarchy> <Hierarchy name="Country name" hasAll="true" primaryKey="cid"> <Table name="dim_country" schema="dw_pp"/> <Level name="Country name" uniqueMembers="false" column="country_name" type="String"> </Level> </Hierarchy> <Hierarchy name="Date from" hasAll="true" primaryKey="cid"> <Table name="dim_country" schema="dw_pp"/> <Level name="Date from" uniqueMembers="false" column="date_from"> </Level> </Hierarchy> <Hierarchy name="Date to" hasAll="true" primaryKey="cid"> <Table name="dim_country" schema="dw_pp"/> <Level name="Date to" uniqueMembers="false" column="date_to"> </Level> </Hierarchy> <Hierarchy name="Version" hasAll="true" primaryKey="cid"> <Table name="dim_country" schema="dw_pp"/> <Level name="Version" uniqueMembers="false" column="version" type="Numeric"> </Level> </Hierarchy> </Dimension> <Dimension name="Dim date"> <Hierarchy name="Calendar month" hasAll="true" primaryKey="date_key"> <Table name="dim_date" schema="dw_pp"/> <Level name="Calendar month" uniqueMembers="false" column="calendar_month" type="Numeric"> </Level> </Hierarchy> <Hierarchy name="Calendar month name" hasAll="true" primaryKey="date_key"> <Table name="dim_date" schema="dw_pp"/> <Level name="Calendar month name" uniqueMembers="false" column="calendar_month_name" type="String"> </Level> </Hierarchy> <Hierarchy name="Calendar week" hasAll="true" primaryKey="date_key"> <Table name="dim_date" schema="dw_pp"/> <Level name="Calendar week" uniqueMembers="false" column="calendar_week" type="Numeric"> </Level> </Hierarchy> <Hierarchy name="Calendar year" hasAll="true" primaryKey="date_key"> <Table name="dim_date" schema="dw_pp"/> <Level name="Calendar year" uniqueMembers="false" column="calendar_year" type="Numeric"> </Level> </Hierarchy> <Hierarchy name="Date" hasAll="true" primaryKey="date_key"> <Table name="dim_date" schema="dw_pp"/> <Level name="Date" uniqueMembers="false" column="date"> </Level> </Hierarchy> <Hierarchy name="Date key" hasAll="true" primaryKey="date_key"> <Table name="dim_date" schema="dw_pp"/> <Level name="Date key" uniqueMembers="false" column="date_key" type="Numeric"> </Level> </Hierarchy> <Hierarchy name="Day of month" hasAll="true" primaryKey="date_key"> <Table name="dim_date" schema="dw_pp"/> <Level name="Day of month" uniqueMembers="false" column="day_of_month" type="Numeric"> </Level> </Hierarchy> <Hierarchy name="Day of week" hasAll="true" primaryKey="date_key"> <Table name="dim_date" schema="dw_pp"/> <Level name="Day of week" uniqueMembers="false" column="day_of_week" type="String"> </Level> </Hierarchy> <Hierarchy name="Day of week name" hasAll="true" primaryKey="date_key"> <Table name="dim_date" schema="dw_pp"/> <Level name="Day of week name" uniqueMembers="false" column="day_of_week_name" type="String"> </Level> </Hierarchy> <Hierarchy name="Day of year" hasAll="true" primaryKey="date_key"> <Table name="dim_date" schema="dw_pp"/> <Level name="Day of year" uniqueMembers="false" column="day_of_year" type="Numeric"> </Level> </Hierarchy> <Hierarchy name="Quarter" hasAll="true" primaryKey="date_key"> <Table name="dim_date" schema="dw_pp"/> <Level name="Quarter" uniqueMembers="false" column="quarter" type="String"> </Level> </Hierarchy> </Dimension> <Dimension name="Dim product"> <Hierarchy name="Brand" hasAll="true" primaryKey="product_pk"> <Table name="dim_product" schema="dw_pp"/> <Level name="Brand" uniqueMembers="false" column="brand" type="String"> </Level> </Hierarchy> <Hierarchy name="Category id" hasAll="true" primaryKey="product_pk"> <Table name="dim_product" schema="dw_pp"/> <Level name="Category id" uniqueMembers="false" column="category_id" type="Numeric"> </Level> </Hierarchy> <Hierarchy name="Category name" hasAll="true" primaryKey="product_pk"> <Table name="dim_product" schema="dw_pp"/> <Level name="Category name" uniqueMembers="false" column="category_name" type="String"> </Level> </Hierarchy> <Hierarchy name="Code" hasAll="true" primaryKey="product_pk"> <Table name="dim_product" schema="dw_pp"/> <Level name="Code" uniqueMembers="false" column="code" type="String"> </Level> </Hierarchy> <Hierarchy name="Created" hasAll="true" primaryKey="product_pk"> <Table name="dim_product" schema="dw_pp"/> <Level name="Created" uniqueMembers="false" column="created"> </Level> </Hierarchy> <Hierarchy name="Created by" hasAll="true" primaryKey="product_pk"> <Table name="dim_product" schema="dw_pp"/> <Level name="Created by" uniqueMembers="false" column="created_by" type="String"> </Level> </Hierarchy> <Hierarchy name="Date from" hasAll="true" primaryKey="product_pk"> <Table name="dim_product" schema="dw_pp"/> <Level name="Date from" uniqueMembers="false" column="date_from"> </Level> </Hierarchy> <Hierarchy name="Date to" hasAll="true" primaryKey="product_pk"> <Table name="dim_product" schema="dw_pp"/> <Level name="Date to" uniqueMembers="false" column="date_to"> </Level> </Hierarchy> <Hierarchy name="Ean" hasAll="true" primaryKey="product_pk"> <Table name="dim_product" schema="dw_pp"/> <Level name="Ean" uniqueMembers="false" column="ean" type="Numeric"> </Level> </Hierarchy> <Hierarchy name="Image location high" hasAll="true" primaryKey="product_pk"> <Table name="dim_product" schema="dw_pp"/> <Level name="Image location high" uniqueMembers="false" column="image_location_high" type="String"> </Level> </Hierarchy> <Hierarchy name="Image location low" hasAll="true" primaryKey="product_pk"> <Table name="dim_product" schema="dw_pp"/> <Level name="Image location low" uniqueMembers="false" column="image_location_low" type="String"> </Level> </Hierarchy> <Hierarchy name="Image location thumb" hasAll="true" primaryKey="product_pk"> <Table name="dim_product" schema="dw_pp"/> <Level name="Image location thumb" uniqueMembers="false" column="image_location_thumb" type="String"> </Level> </Hierarchy> <Hierarchy name="Last modified by price" hasAll="true" primaryKey="product_pk"> <Table name="dim_product" schema="dw_pp"/> <Level name="Last modified by price" uniqueMembers="false" column="last_modified_by_price" type="String"> </Level> </Hierarchy> <Hierarchy name="Last modifiedby product" hasAll="true" primaryKey="product_pk"> <Table name="dim_product" schema="dw_pp"/> <Level name="Last modifiedby product" uniqueMembers="false" column="last_modifiedby_product" type="String"> </Level> </Hierarchy> <Hierarchy name="Level0 parent category id" hasAll="true" primaryKey="product_pk"> <Table name="dim_product" schema="dw_pp"/> <Level name="Level0 parent category id" uniqueMembers="false" column="level0_parent_category_id" type="Numeric"> </Level> </Hierarchy> <Hierarchy name="Level0 parent category name" hasAll="true" primaryKey="product_pk"> <Table name="dim_product" schema="dw_pp"/> <Level name="Level0 parent category name" uniqueMembers="false" column="level0_parent_category_name" type="String"> </Level> </Hierarchy> <Hierarchy name="Level1 parent category id" hasAll="true" primaryKey="product_pk"> <Table name="dim_product" schema="dw_pp"/> <Level name="Level1 parent category id" uniqueMembers="false" column="level1_parent_category_id" type="Numeric"> </Level> </Hierarchy> <Hierarchy name="Level1 parent category name" hasAll="true" primaryKey="product_pk"> <Table name="dim_product" schema="dw_pp"/> <Level name="Level1 parent category name" uniqueMembers="false" column="level1_parent_category_name" type="String"> </Level> </Hierarchy> <Hierarchy name="Manufacturer id" hasAll="true" primaryKey="product_pk"> <Table name="dim_product" schema="dw_pp"/> <Level name="Manufacturer id" uniqueMembers="false" column="manufacturer_id" type="Numeric"> </Level> </Hierarchy> <Hierarchy name="Modified product" hasAll="true" primaryKey="product_pk"> <Table name="dim_product" schema="dw_pp"/> <Level name="Modified product" uniqueMembers="false" column="modified_product"> </Level> </Hierarchy> <Hierarchy name="Price" hasAll="true" primaryKey="product_pk"> <Table name="dim_product" schema="dw_pp"/> <Level name="Price" uniqueMembers="false" column="price" type="Numeric"> </Level> </Hierarchy> <Hierarchy name="Price with shipping" hasAll="true" primaryKey="product_pk"> <Table name="dim_product" schema="dw_pp"/> <Level name="Price with shipping" uniqueMembers="false" column="price_with_shipping" type="Numeric"> </Level> </Hierarchy> <Hierarchy name="Product currency code" hasAll="true" primaryKey="product_pk"> <Table name="dim_product" schema="dw_pp"/> <Level name="Product currency code" uniqueMembers="false" column="product_currency_code" type="String"> </Level> </Hierarchy> <Hierarchy name="Product id" hasAll="true" primaryKey="product_pk"> <Table name="dim_product" schema="dw_pp"/> <Level name="Product id" uniqueMembers="false" column="product_id" type="Numeric"> </Level> </Hierarchy> <Hierarchy name="Product info id" hasAll="true" primaryKey="product_pk"> <Table name="dim_product" schema="dw_pp"/> <Level name="Product info id" uniqueMembers="false" column="product_info_id" type="Numeric"> </Level> </Hierarchy> <Hierarchy name="Product name" hasAll="true" primaryKey="product_pk"> <Table name="dim_product" schema="dw_pp"/> <Level name="Product name" uniqueMembers="false" column="product_name" type="String"> </Level> </Hierarchy> <Hierarchy name="Product page type" hasAll="true" primaryKey="product_pk"> <Table name="dim_product" schema="dw_pp"/> <Level name="Product page type" uniqueMembers="false" column="product_page_type" type="String"> </Level> </Hierarchy> <Hierarchy name="Product pk" hasAll="true" primaryKey="product_pk"> <Table name="dim_product" schema="dw_pp"/> <Level name="Product pk" uniqueMembers="false" column="product_pk" type="Numeric"> </Level> </Hierarchy> <Hierarchy name="Quality" hasAll="true" primaryKey="product_pk"> <Table name="dim_product" schema="dw_pp"/> <Level name="Quality" uniqueMembers="false" column="quality" type="String"> </Level> </Hierarchy> <Hierarchy name="Shop active" hasAll="true" primaryKey="product_pk"> <Table name="dim_product" schema="dw_pp"/> <Level name="Shop active" uniqueMembers="false" column="shop_active" type="String"> </Level> </Hierarchy> <Hierarchy name="Shop id" hasAll="true" primaryKey="product_pk"> <Table name="dim_product" schema="dw_pp"/> <Level name="Shop id" uniqueMembers="false" column="shop_id" type="Numeric"> </Level> </Hierarchy> <Hierarchy name="Shop paying" hasAll="true" primaryKey="product_pk"> <Table name="dim_product" schema="dw_pp"/> <Level name="Shop paying" uniqueMembers="false" column="shop_paying" type="String"> </Level> </Hierarchy> <Hierarchy name="Status product" hasAll="true" primaryKey="product_pk"> <Table name="dim_product" schema="dw_pp"/> <Level name="Status product" uniqueMembers="false" column="status_product" type="String"> </Level> </Hierarchy> <Hierarchy name="Tstamp" hasAll="true" primaryKey="product_pk"> <Table name="dim_product" schema="dw_pp"/> <Level name="Tstamp" uniqueMembers="false" column="tstamp"> </Level> </Hierarchy> <Hierarchy name="Version" hasAll="true" primaryKey="product_pk"> <Table name="dim_product" schema="dw_pp"/> <Level name="Version" uniqueMembers="false" column="version" type="Numeric"> </Level> </Hierarchy> </Dimension> <Dimension name="Dim shop"> <Hierarchy name="Ac id" hasAll="true" primaryKey="shop_pk"> <Table name="dim_shop" schema="dw_pp"/> <Level name="Ac id" uniqueMembers="false" column="ac_id" type="String"> </Level> </Hierarchy> <Hierarchy name="Ac type" hasAll="true" primaryKey="shop_pk"> <Table name="dim_shop" schema="dw_pp"/> <Level name="Ac type" uniqueMembers="false" column="ac_type" type="String"> </Level> </Hierarchy> <Hierarchy name="Account status" hasAll="true" primaryKey="shop_pk"> <Table name="dim_shop" schema="dw_pp"/> <Level name="Account status" uniqueMembers="false" column="account_status" type="String"> </Level> </Hierarchy> <Hierarchy name="Afl network" hasAll="true" primaryKey="shop_pk"> <Table name="dim_shop" schema="dw_pp"/> <Level name="Afl network" uniqueMembers="false" column="afl_network" type="String"> </Level> </Hierarchy> <Hierarchy name="Afl param" hasAll="true" primaryKey="shop_pk"> <Table name="dim_shop" schema="dw_pp"/> <Level name="Afl param" uniqueMembers="false" column="afl_param" type="String"> </Level> </Hierarchy> <Hierarchy name="Capping" hasAll="true" primaryKey="shop_pk"> <Table name="dim_shop" schema="dw_pp"/> <Level name="Capping" uniqueMembers="false" column="capping" type="Numeric"> </Level> </Hierarchy> <Hierarchy name="Co id" hasAll="true" primaryKey="shop_pk"> <Table name="dim_shop" schema="dw_pp"/> <Level name="Co id" uniqueMembers="false" column="co_id" type="String"> </Level> </Hierarchy> <Hierarchy name="Co name" hasAll="true" primaryKey="shop_pk"> <Table name="dim_shop" schema="dw_pp"/> <Level name="Co name" uniqueMembers="false" column="co_name" type="String"> </Level> </Hierarchy> <Hierarchy name="Co type" hasAll="true" primaryKey="shop_pk"> <Table name="dim_shop" schema="dw_pp"/> <Level name="Co type" uniqueMembers="false" column="co_type" type="String"> </Level> </Hierarchy> <Hierarchy name="Contract number" hasAll="true" primaryKey="shop_pk"> <Table name="dim_shop" schema="dw_pp"/> <Level name="Contract number" uniqueMembers="false" column="contract_number" type="String"> </Level> </Hierarchy> <Hierarchy name="Contract type" hasAll="true" primaryKey="shop_pk"> <Table name="dim_shop" schema="dw_pp"/> <Level name="Contract type" uniqueMembers="false" column="contract_type" type="String"> </Level> </Hierarchy> <Hierarchy name="Country code" hasAll="true" primaryKey="shop_pk"> <Table name="dim_shop" schema="dw_pp"/> <Level name="Country code" uniqueMembers="false" column="country_code" type="String"> </Level> </Hierarchy> <Hierarchy name="Cpc" hasAll="true" primaryKey="shop_pk"> <Table name="dim_shop" schema="dw_pp"/> <Level name="Cpc" uniqueMembers="false" column="cpc" type="Numeric"> </Level> </Hierarchy> <Hierarchy name="Cpc earning" hasAll="true" primaryKey="shop_pk"> <Table name="dim_shop" schema="dw_pp"/> <Level name="Cpc earning" uniqueMembers="false" column="cpc_earning" type="Numeric"> </Level> </Hierarchy> <Hierarchy name="Cpo" hasAll="true" primaryKey="shop_pk"> <Table name="dim_shop" schema="dw_pp"/> <Level name="Cpo" uniqueMembers="false" column="cpo" type="Numeric"> </Level> </Hierarchy> <Hierarchy name="Created" hasAll="true" primaryKey="shop_pk"> <Table name="dim_shop" schema="dw_pp"/> <Level name="Created" uniqueMembers="false" column="created"> </Level> </Hierarchy> <Hierarchy name="Currency" hasAll="true" primaryKey="shop_pk"> <Table name="dim_shop" schema="dw_pp"/> <Level name="Currency" uniqueMembers="false" column="currency" type="String"> </Level> </Hierarchy> <Hierarchy name="Date from" hasAll="true" primaryKey="shop_pk"> <Table name="dim_shop" schema="dw_pp"/> <Level name="Date from" uniqueMembers="false" column="date_from"> </Level> </Hierarchy> <Hierarchy name="Date to" hasAll="true" primaryKey="shop_pk"> <Table name="dim_shop" schema="dw_pp"/> <Level name="Date to" uniqueMembers="false" column="date_to"> </Level> </Hierarchy> <Hierarchy name="Description" hasAll="true" primaryKey="shop_pk"> <Table name="dim_shop" schema="dw_pp"/> <Level name="Description" uniqueMembers="false" column="description" type="String"> </Level> </Hierarchy> <Hierarchy name="Image location high" hasAll="true" primaryKey="shop_pk"> <Table name="dim_shop" schema="dw_pp"/> <Level name="Image location high" uniqueMembers="false" column="image_location_high" type="String"> </Level> </Hierarchy> <Hierarchy name="Image location low" hasAll="true" primaryKey="shop_pk"> <Table name="dim_shop" schema="dw_pp"/> <Level name="Image location low" uniqueMembers="false" column="image_location_low" type="String"> </Level> </Hierarchy> <Hierarchy name="Image location thumb" hasAll="true" primaryKey="shop_pk"> <Table name="dim_shop" schema="dw_pp"/> <Level name="Image location thumb" uniqueMembers="false" column="image_location_thumb" type="String"> </Level> </Hierarchy> <Hierarchy name="Last modifiedby" hasAll="true" primaryKey="shop_pk"> <Table name="dim_shop" schema="dw_pp"/> <Level name="Last modifiedby" uniqueMembers="false" column="last_modifiedby" type="String"> </Level> </Hierarchy> <Hierarchy name="Modified" hasAll="true" primaryKey="shop_pk"> <Table name="dim_shop" schema="dw_pp"/> <Level name="Modified" uniqueMembers="false" column="modified"> </Level> </Hierarchy> <Hierarchy name="No deep links" hasAll="true" primaryKey="shop_pk"> <Table name="dim_shop" schema="dw_pp"/> <Level name="No deep links" uniqueMembers="false" column="no_deep_links" type="Boolean"> </Level> </Hierarchy> <Hierarchy name="Opening hours" hasAll="true" primaryKey="shop_pk"> <Table name="dim_shop" schema="dw_pp"/> <Level name="Opening hours" uniqueMembers="false" column="opening_hours" type="String"> </Level> </Hierarchy> <Hierarchy name="Pay status" hasAll="true" primaryKey="shop_pk"> <Table name="dim_shop" schema="dw_pp"/> <Level name="Pay status" uniqueMembers="false" column="pay_status" type="String"> </Level> </Hierarchy> <Hierarchy name="Score" hasAll="true" primaryKey="shop_pk"> <Table name="dim_shop" schema="dw_pp"/> <Level name="Score" uniqueMembers="false" column="score" type="Numeric"> </Level> </Hierarchy> <Hierarchy name="Shipping details" hasAll="true" primaryKey="shop_pk"> <Table name="dim_shop" schema="dw_pp"/> <Level name="Shipping details" uniqueMembers="false" column="shipping_details" type="String"> </Level> </Hierarchy> <Hierarchy name="Shipping fee" hasAll="true" primaryKey="shop_pk"> <Table name="dim_shop" schema="dw_pp"/> <Level name="Shipping fee" uniqueMembers="false" column="shipping_fee" type="Numeric"> </Level> </Hierarchy> <Hierarchy name="Shop id" hasAll="true" primaryKey="shop_pk"> <Table name="dim_shop" schema="dw_pp"/> <Level name="Shop id" uniqueMembers="false" column="shop_id" type="Numeric"> </Level> </Hierarchy> <Hierarchy name="Shop name" hasAll="true" primaryKey="shop_pk"> <Table name="dim_shop" schema="dw_pp"/> <Level name="Shop name" uniqueMembers="false" column="shop_name" type="String"> </Level> </Hierarchy> <Hierarchy name="Shop pk" hasAll="true" primaryKey="shop_pk"> <Table name="dim_shop" schema="dw_pp"/> <Level name="Shop pk" uniqueMembers="false" column="shop_pk" type="Numeric"> </Level> </Hierarchy> <Hierarchy name="Start date" hasAll="true" primaryKey="shop_pk"> <Table name="dim_shop" schema="dw_pp"/> <Level name="Start date" uniqueMembers="false" column="start_date"> </Level> </Hierarchy> <Hierarchy name="Status" hasAll="true" primaryKey="shop_pk"> <Table name="dim_shop" schema="dw_pp"/> <Level name="Status" uniqueMembers="false" column="status" type="String"> </Level> </Hierarchy> <Hierarchy name="Target country" hasAll="true" primaryKey="shop_pk"> <Table name="dim_shop" schema="dw_pp"/> <Level name="Target country" uniqueMembers="false" column="target_country" type="String"> </Level> </Hierarchy> <Hierarchy name="Type" hasAll="true" primaryKey="shop_pk"> <Table name="dim_shop" schema="dw_pp"/> <Level name="Type" uniqueMembers="false" column="type" type="String"> </Level> </Hierarchy> <Hierarchy name="Url" hasAll="true" primaryKey="shop_pk"> <Table name="dim_shop" schema="dw_pp"/> <Level name="Url" uniqueMembers="false" column="url" type="String"> </Level> </Hierarchy> <Hierarchy name="Url policy" hasAll="true" primaryKey="shop_pk"> <Table name="dim_shop" schema="dw_pp"/> <Level name="Url policy" uniqueMembers="false" column="url_policy" type="String"> </Level> </Hierarchy> <Hierarchy name="Version" hasAll="true" primaryKey="shop_pk"> <Table name="dim_shop" schema="dw_pp"/> <Level name="Version" uniqueMembers="false" column="version" type="Numeric"> </Level> </Hierarchy> </Dimension> <Cube name="cube"> <Table name="fc_analytics" schema="dw_pp"/> <DimensionUsage name="Dim country" source="Dim country" foreignKey="country_fk"/> <DimensionUsage name="Dim date" source="Dim date" foreignKey="date_fk"/> <DimensionUsage name="Dim product" source="Dim product" foreignKey="product_fk"/> <DimensionUsage name="Dim shop" source="Dim shop" foreignKey="shop_fk"/> <Measure name="Country fk" column="country_fk" aggregator="sum" formatString="#"/> <Measure name="Date fk" column="date_fk" aggregator="sum" formatString="#"/> <Measure name="Product fk" column="product_fk" aggregator="sum" formatString="#"/> <Measure name="Ser id" column="ser_id" aggregator="sum" formatString="#"/> <Measure name="Shop fk" column="shop_fk" aggregator="sum" formatString="#"/> <Measure name="Measure1" column="M1" aggregator="sum" formatString="#"/> <Measure name="Measure2" column="M2" aggregator="sum" formatString="#"/> <Measure name="Measure3" column="M3" aggregator="sum" formatString="#"/> </Cube> </Schema>**strong text** The query runs. But the values are incorrect. Am I missing something here ?
This strikes me a slightly strange: MEMBER [Dim shop.Shop id].[Shop count] AS Count([Dim shop.Shop id].Members, EXCLUDEEMPTY) It looks like a measure so why not add it to the [Measures] hierarchy? MEMBER [Measures].[Shop count] AS Count([Dim shop.Shop id].Members, EXCLUDEEMPTY) You might need to add some context to the measure: MEMBER [Measures].[Shop count] AS Count( nonempty( [Dim shop.Shop id].Members ,{[~ROWS_Dim country].currentmember, [~ROWS_Dim shop].currentmember}) ) ) I'm unsure what standard mdx mondrian will use but also the following would be better with the keyword existing: MEMBER [Measures].[Shop count] AS Count( nonempty( EXISTING [Dim shop.Shop id].Members ,{[~ROWS_Dim country].currentmember, [~ROWS_Dim shop].currentmember}) ) )
You should try Hierarchize ( [DimShops].[Shop Id].members)
The problem was with my fact table. Apparently NonEmptyCrossJoin() does a scan of the fact table first and excludes dimension entries without a fact table entry (which is not what I want. I want to query the dimension independently) This explains the perils of using NonEmptyCrossJoin() I used FILTER(CROSSJOIN(,) AS S, NOT IsEmpty(S.Current)) instead.
How to add level to column to result MDX in mondrian
I have the following table created by the following MDX SELECT { [Measures].numTickets }ON COLUMNS, { Descendants(DateCreacion.Children, DateCreacion.Month) }ON ROWS FROM tickets The thing is that i want to add another column to the numTickets but every time i add a dimension to the column, i get an empty column. select {[Clinica].Children} ON COLUMNS, {Descendants([DateCreacion].Children, [DateCreacion.YQMD].[Month])} ON ROWS from [tickets] How would i show the same data as the first picture but in the second format? <Schema name="New Schema1"> <Cube name="tickets" visible="true" cache="true" enabled="true"> <Table name="fact"> </Table> <Dimension type="TimeDimension" visible="true" foreignKey="fecha_tickets_id" name="DateCreacion"> <Hierarchy name="YQMD" visible="true" hasAll="true"> <Table name="dim_fecha_creacion_tickets" alias=""> </Table> <Level name="Year" visible="true" column="año" type="Numeric" uniqueMembers="false" levelType="TimeYears"> </Level> <Level name="Quarter" visible="true" column="cuarto" type="Numeric" uniqueMembers="false" levelType="TimeQuarters"> </Level> <Level name="Month" visible="true" column="mes" type="Numeric" uniqueMembers="false" levelType="TimeMonths"> </Level> <Level name="Day" visible="true" column="dia" type="Numeric" uniqueMembers="false" levelType="TimeDays"> <Property name="date_iso" column="date_iso" type="Numeric"> </Property> </Level> </Hierarchy> </Dimension> <Dimension type="StandardDimension" visible="true" foreignKey="clinica_id" name="Clinica"> <Hierarchy name="New Hierarchy 0" visible="true" hasAll="true"> <Table name="dim_posicion" alias=""> </Table> <Level name="Posicion" visible="true" column="sigla" type="String" uniqueMembers="false"> </Level> </Hierarchy> </Dimension> <Measure name="numTickets" column="idTicket" datatype="Numeric" aggregator="count" visible="true"> </Measure> </Cube> </Schema>
When adding the [Clinica].Children to the columns, you removed the measures. You probably want to keep them, using a cross join, which can be stated using the * operator in MDX: Either select {[Clinica].Children} * { [Measures].numTickets } ON COLUMNS, ... or select { [Measures].numTickets } * {[Clinica].Children} ON COLUMNS, ... depending on the order of columns you want to see.