How to load and process text data on upper-levels of a dimension in icCube? - mdx

I want to load textual data on any member in a natural hierarchy in icCube, but I am not able to display the textual values with MDX for the upper-levels.
Consider the following (natural) hierarchy, data and expected outcome:
(It might look a bit weird, but icCube allows to have the leaf empty for SUB013 and SUB014.)
As you can see in the desired outcome in the picture above, I expect "voila" to be displayed on SUB015.
But, I can not get it to work. See the outcome I get with MDX:
I have the following issues:
the value is empty (I have used the no aggregation type on text)
another observation is that also the amount is empty for a no aggregation type
Is this solvable, somehow?
(enclosed as a snippet - not runnable - the schema I used, which you can upload in your instance of icCube)
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<schemaFactory revisionNumber="77">
<schemaDefinition name="text on sub-total" description="" group="Research" loadOnStartup="false">
<activateIncrementalLoad>false</activateIncrementalLoad>
<useUnknownMembersInFacts>false</useUnknownMembersInFacts>
<autoCleanUpTableColumns>false</autoCleanUpTableColumns>
<useFactPartitioning>false</useFactPartitioning>
<callGarbageCollector>NONE</callGarbageCollector>
<backup>NONE</backup>
<nonEmptyCachePolicy>NONE</nonEmptyCachePolicy>
<nonEmptyCacheType>REGULAR</nonEmptyCacheType>
<nonEmptyCachePersistency>MEMORY</nonEmptyCachePersistency>
<storagePolicy>DEFAULT</storagePolicy>
<hierarchyUniqueNameStyle>IncludeDimensionName</hierarchyUniqueNameStyle>
<inMemoryDS name="manual">
<memoryDataTable tableName="data" rowLimit="-1" id="3c476e37-708d-4066-831c-89508134beb7">
<column name="dim" tableType="STRING" type="STRING" selected="true" primaryKey="false" nullObjectAsString=""/>
<column name="costs" tableType="STRING" type="DOUBLE" selected="true" primaryKey="false" nullObjectAsString=""/>
<column name="text" tableType="STRING" type="STRING" selected="true" primaryKey="false" nullObjectAsString=""/>
<addRowNumber>false</addRowNumber>
<stringDateConverter></stringDateConverter>
<trimStrings>true</trimStrings>
<columnSeparator>\t</columnSeparator>
<commentMarker>#</commentMarker>
<dataAsString>dim costs text
CHILD001
CHILD002
CHILD003 10 hi
CHILD004
CHILD005
SUB013 59 salut
SUB014 69 bonjour
SUB015 180 voila
</dataAsString>
</memoryDataTable>
<memoryDataTable tableName="dim" rowLimit="-1" id="373a4b14-5b7d-441d-91c0-caabeb670936">
<column name="SubTotal" tableType="STRING" type="STRING" selected="true" primaryKey="false" nullObjectAsString=""/>
<column name="Leaf" tableType="STRING" type="STRING" selected="true" primaryKey="false" nullObjectAsString=""/>
<addRowNumber>false</addRowNumber>
<stringDateConverter></stringDateConverter>
<trimStrings>true</trimStrings>
<columnSeparator>\t</columnSeparator>
<commentMarker>#</commentMarker>
<dataAsString>SubTotal Leaf
SUB013
SUB014
SUB015 CHILD001
SUB015 CHILD002
SUB015 CHILD003
SUB015 CHILD004
SUB015 CHILD005
</dataAsString>
</memoryDataTable>
</inMemoryDS>
<multiLevelDimension dataTableId="373a4b14-5b7d-441d-91c0-caabeb670936" isTimeDimension="false" isDefaultTimeDimension="false" isIndexingByRange="false" unknownMemberName="" id="6b08783b-b33c-4499-b253-212753be23fd" name="Dim">
<multiLevelHierarchy hasAllLevel="true" allLevelName="All-L" allMemberName="All-M" name="Dim" isDefault="true" defaultMemberName="">
<factAggregationType>MEMBER_AND_ANCESTORS</factAggregationType>
<level name="subtotal" nameUnique="true" nameUniqueInParent="false" keyUnique="true" ignoreNameCollision="false">
<column name="SubTotal"/>
<nameCol name="SubTotal"/>
<orderType>NONE</orderType>
<orderKind>ASC</orderKind>
</level>
<level name="leaf" nameUnique="true" nameUniqueInParent="false" keyUnique="true" ignoreNameCollision="false">
<column name="Leaf"/>
<nameCol name="Leaf"/>
<orderType>NONE</orderType>
<orderKind>ASC</orderKind>
</level>
</multiLevelHierarchy>
</multiLevelDimension>
<cube id="1c361ef2-ebba-475f-9cc8-83910e4530e2" name="data" description="">
<defaultFacts measureGroupName="Facts" partitioningLevelName="" partitioningType="NONE" newGeneration="true" dataTableId="3c476e37-708d-4066-831c-89508134beb7" aggregateDataSourceFacts="false" unresolvedRowsBehavior="ERROR">
<rowFactAggregationType>ADD_ROW</rowFactAggregationType>
<measure name="costs sum" aggregationType="SUM">
<rollupHierarchy></rollupHierarchy>
<dataColumn name="costs"/>
<cellProperties></cellProperties>
<emptyIsZero>false</emptyIsZero>
</measure>
<measure name="costs max" aggregationType="MAX">
<rollupHierarchy></rollupHierarchy>
<dataColumn name="costs"/>
<cellProperties></cellProperties>
<emptyIsZero>false</emptyIsZero>
</measure>
<measure name="costs no agg" aggregationType="NONE">
<rollupHierarchy></rollupHierarchy>
<dataColumn name="costs"/>
<cellProperties></cellProperties>
<emptyIsZero>false</emptyIsZero>
</measure>
<measure name="text max" aggregationType="MAX">
<rollupHierarchy></rollupHierarchy>
<dataColumn name="text"/>
<cellProperties></cellProperties>
<emptyIsZero>false</emptyIsZero>
</measure>
<measure name="text no agg" aggregationType="NONE">
<rollupHierarchy></rollupHierarchy>
<dataColumn name="text"/>
<cellProperties></cellProperties>
<emptyIsZero>false</emptyIsZero>
</measure>
<links dimensionId="6b08783b-b33c-4499-b253-212753be23fd">
<viewLinks type="ALL_LEVELS">
<toColumns name="dim"/>
</viewLinks>
</links>
</defaultFacts>
</cube>
<localization enabled="false"/>
<script>
<content>
</content>
</script>
</schemaDefinition>
</schemaFactory>

In icCube a node value, even if leaf, can be the result of an aggregation over multiple facts rows. When you specify, NO_AGGREGATION, as aggregation method the NULL is returned if more than one single row is in play.
For you example as SUB015 has a child with value, CHILD003. And the dimension is defined with 'Fact Aggr. Type' as 'Members and Ancestors'.
Two solutions :
1) Add a Dimension member property that is retrieved using a calculated member.
2) Use a dimension with 'Fact Aggr. Type' as 'Members' but you will get wrong cost.

Related

How to Visualize properties with Mdx

I m new to the mdx query.
I have spatial properties that i want to visualize in a geomondrian table, this is the schema of simple_geofoodmart.xml :
<!-- spatial store dimension -->
<Dimension name="Store" foreignKey="store_id">
<Hierarchy hasAll="true" primaryKey="store_id" primaryKeyTable="geostore_store">
<Join leftKey="store_city_id_fk" rightKey="store_city_id"
rightAlias="geostore_city">
<Table name="geostore_store" />
<Join leftKey="store_state_id_fk" rightKey="store_state_id"
rightAlias="geostore_state">
<Table name="geostore_city" />
<Join leftKey="store_country_id_fk" rightKey="store_country_id">
<Table name="geostore_state" />
<Table name="geostore_country" />
</Join>
</Join>
</Join>
<Level name="Store Country" table="geostore_country" column="store_country_name"
uniqueMembers="true">
<Property name="geom" column="store_country_geom" type="Geometry" />
</Level>
<Level name="Store State" table="geostore_state" column="store_state_name"
uniqueMembers="true">
<Property name="geom" column="store_state_geom" type="Geometry" />
</Level>
<Level name="Store City" table="geostore_city" column="store_city_name"
uniqueMembers="false">
<Property name="geom" column="store_city_geom" type="Geometry" />
</Level>
<Level name="Store Name" table="geostore_store" column="store_name"
uniqueMembers="true">
<Property name="Store Type" column="store_type"/>
<Property name="Store Manager" column="store_manager"/>
<Property name="Store Sqft" column="store_sqft" type="Numeric"/>
<Property name="Street address" column="store_street_address" type="String"/>
</Level>
</Hierarchy>
</Dimension>
I want to get the "geom" proporty in columns and the products in rows
Usually you do it like that:
SELECT
[Measure] ON COLUMNS,
NON EMPTY [Store].MEMBERS
DIMENSION PROPERTIES
[Store].[geom] ON ROWS
FROM [Cube]
You list the DIMENSION PROPERTIES in the dimension axis
Actually i found a solution by tricking the mdx examples given in the Basic interface for ad hoc GeoMDX queries in localhost index
with member Measures.geo as [Store].CurrentMember.Properties("geom")
select {[Measures].geo} ON rows,
{[Store].[All Stores].[USA]} ON columns
from [Sales]

how to use process management start and end dates in the ranged dimension II in icCube

icCube can process ranged dimensions to solve complex modeling solutions for process management. Here an example is given for order date and ship date. Nice example, which is almost applicable, but not entirely.
I want to display changes with their latest phase. The changes come from an ITSM software SAAS solution. Simplified, a change flows through the following stages:
to be authorized
work in progress
to be reviewed
closed
Each stage has a start- and end date. And there are no gaps.
Now I would like to show the life-cycle of a change (or multiple changes) in a chart using the solution of the ranged II dimension. But I get the following chart:
How can I produce the required outcome. Meaning, only show the latest stage of a change during a certain time interval?
Both solutions work.
1) For the range solution, you need to add a measure that uses CLOSE aggregation mode on the Time Dimension as we want the 'state' as of the last day of any time period. Also, both dates are included when using range, so end date should be one day before the start of the next bucket.
You can use Sum or Eval instead of Aggregate. Eval will be faster if the same time period is reused multiple times in the same query as the subcube is cached.
CREATE MEMBER [#changes ITD 2] as Eval( compactSet(NULL:[Time].[Time].currentMember) , ([Time].[Time].defaultMember,[Measures].[# changes (based on delta)]) )
2) For Purple Frog one, I'd use compactSet for the calculated member as without the calculated function will quickly degradated when getting more an more data. It's 365 days for each year, so if you've 10 years you'll have 3650 sums without de compactSet. With the compactSet, we can use it as the measure is additive, instead of 10 years will have something like, 9 (years) + 11 (months) + 31(days) , that is a lot less on the worst scenario.
Which one to use ?
1) It uses more memory but the performance is faster and amazingly stable as we're using the last day of the period value. Adding other time hierarchies might give some unexpected results.
CREATE MEMBER [#changes ITD] as Aggregate( compactSet(NULL:[Time].[Time].currentMember) , [Measures].[# changes (based on delta)] )
2) It uses less memory, we only save two points, but it a bit slower.
On both I'd pay attention that adding, and using, other Time hierarchies and Time dimensions might give some 'strange' results.
Here the updated schema ( [#changes ITD] definition is included)
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<schemaFactory revisionNumber="11">
<schemaDefinition name="Phases - ranged dimension II" description="issue description StackOverflow" group="StackOverflow" loadOnStartup="false">
<activateIncrementalLoad>false</activateIncrementalLoad>
<useUnknownMembersInFacts>false</useUnknownMembersInFacts>
<autoCleanUpTableColumns>false</autoCleanUpTableColumns>
<useFactPartitioning>false</useFactPartitioning>
<callGarbageCollector>NONE</callGarbageCollector>
<backup>NONE</backup>
<nonEmptyCachePolicy>NONE</nonEmptyCachePolicy>
<nonEmptyCacheType>REGULAR</nonEmptyCacheType>
<nonEmptyCachePersistency>MEMORY</nonEmptyCachePersistency>
<storagePolicy>DEFAULT</storagePolicy>
<hierarchyUniqueNameStyle>IncludeDimensionName</hierarchyUniqueNameStyle>
<inMemoryDS name="manual">
<memoryDataTable tableName="facts" rowLimit="-1" id="c41cc2b5-1412-4da1-8e0e-3bd1b07e9d66">
<column name="start" tableType="STRING" type="DATE" selected="true" primaryKey="false" nullObjectAsString=""/>
<column name="end" tableType="STRING" type="DATE" selected="true" primaryKey="false" nullObjectAsString=""/>
<column name="phase" tableType="STRING" type="STRING" selected="true" primaryKey="false" nullObjectAsString=""/>
<column name="chg" tableType="STRING" type="STRING" selected="true" primaryKey="false" nullObjectAsString=""/>
<column name="#changes" tableType="STRING" type="INTEGER" selected="true" primaryKey="false" nullObjectAsString=""/>
<addRowNumber>false</addRowNumber>
<stringDateConverter>d MMM, yyyy</stringDateConverter>
<stringDateConverterLocale>en</stringDateConverterLocale>
<trimStrings>true</trimStrings>
<columnSeparator>;</columnSeparator>
<commentMarker>#</commentMarker>
<dataAsString>start;end;phase;chg;#changes
1 January, 2018;31 January, 2018; a;chg001;1
1 February, 2018;4 March, 2018;b;chg001;1
5 March, 2018;19 March, 2018;c;chg001;1
20 March, 2018;19 March, 2018;d;chg001;1
20 March, 2018;2 June, 2018;e;chg001;1
</dataAsString>
</memoryDataTable>
<memoryDataTable tableName="phases" rowLimit="-1" id="b24aaebb-7ce3-42a9-bab0-a54bc4c4b896">
<column name="phase" tableType="STRING" type="STRING" selected="true" primaryKey="false" nullObjectAsString=""/>
<addRowNumber>false</addRowNumber>
<stringDateConverter></stringDateConverter>
<trimStrings>true</trimStrings>
<columnSeparator>,</columnSeparator>
<commentMarker>#</commentMarker>
<dataAsString>phase
a
b
c
d
e
</dataAsString>
</memoryDataTable>
<memoryDataTable tableName="changes" rowLimit="-1" id="8ba9aaca-0d93-49b1-851f-4f325e05bbbe">
<column name="chg" tableType="STRING" type="STRING" selected="true" primaryKey="false" nullObjectAsString=""/>
<addRowNumber>false</addRowNumber>
<stringDateConverter></stringDateConverter>
<trimStrings>true</trimStrings>
<columnSeparator>;</columnSeparator>
<commentMarker>#</commentMarker>
<dataAsString>chg
chg001
chg002
chg003</dataAsString>
</memoryDataTable>
<memoryDataTable tableName="facts - delta" rowLimit="-1" id="aea29582-84e2-4ef4-a169-5d9549141ba6">
<column name="date" tableType="STRING" type="DATE" selected="true" primaryKey="false" nullObjectAsString=""/>
<column name="phase" tableType="STRING" type="STRING" selected="true" primaryKey="false" nullObjectAsString=""/>
<column name="chg" tableType="STRING" type="STRING" selected="true" primaryKey="false" nullObjectAsString=""/>
<column name="delta" tableType="STRING" type="INTEGER" selected="true" primaryKey="false" nullObjectAsString=""/>
<addRowNumber>false</addRowNumber>
<stringDateConverter>d MMM, yyyy</stringDateConverter>
<stringDateConverterLocale>en</stringDateConverterLocale>
<trimStrings>true</trimStrings>
<columnSeparator>;</columnSeparator>
<commentMarker>#</commentMarker>
<dataAsString>date;phase;chg;delta
1 January, 2018;a;chg001;1
1 February, 2018;b;chg001;1
5 March, 2018;c;chg001;1
20 March, 2018;d;chg001;1
20 March, 2018;e;chg001;1
1 February, 2018;a;chg001; -1
5 March, 2018;b;chg001;-1
20 March, 2018;c;chg001;-1
20 March, 2018;d;chg001;-1
13 June, 2018;e;chg001;-1
</dataAsString>
</memoryDataTable>
</inMemoryDS>
<multiLevelDimension dataTableId="8ba9aaca-0d93-49b1-851f-4f325e05bbbe" isTimeDimension="false" isDefaultTimeDimension="false" isIndexingByRange="false" id="0c4cf980-73d9-4c42-ae47-a300421c29a2" name="Change">
<multiLevelHierarchy hasAllLevel="true" allLevelName="All-Level" allMemberName="All" name="Change" isDefault="true">
<level name="change" nameUnique="false" nameUniqueInParent="false" keyUnique="false" ignoreNameCollision="false">
<nameCol name="chg"/>
<orderType>BY_NAME</orderType>
<orderKind>ASC</orderKind>
</level>
</multiLevelHierarchy>
</multiLevelDimension>
<multiLevelDimension dataTableId="b24aaebb-7ce3-42a9-bab0-a54bc4c4b896" isTimeDimension="false" isDefaultTimeDimension="false" isIndexingByRange="false" id="ed48052e-2c11-48a8-9407-c4854b163cb6" name="Phase">
<multiLevelHierarchy hasAllLevel="true" allLevelName="All-Level" allMemberName="All" name="Phase" isDefault="true">
<level name="phase" nameUnique="false" nameUniqueInParent="false" keyUnique="false" ignoreNameCollision="false">
<nameCol name="phase"/>
<orderType>BY_NAME</orderType>
<orderKind>ASC</orderKind>
</level>
</multiLevelHierarchy>
</multiLevelDimension>
<timeWizardDimension isDefaultTimeDimension="false" isIndexingByRange="true" from="2018-06-01T00:00:00.000" to="2018-07-31T00:00:00.000" dataTableId="c41cc2b5-1412-4da1-8e0e-3bd1b07e9d66" unknownMemberName="" id="b545bf65-ec47-4267-a4f1-a8df35096bc4" name="Time">
<timeHierarchy hasAllLevel="true" allLevelName="All-L" allMemberName="All-M" name="Time" isDefault="true" defaultMemberName="">
<factAggregationType>MEMBER_AND_ANCESTORS</factAggregationType>
<level name="Year" type="YEAR">
<useRelativeKey>false</useRelativeKey>
</level>
<level name="Month" type="MONTH" nameFormat="">
<useRelativeKey>false</useRelativeKey>
</level>
<level name="Day" type="DAY" nameFormat="">
<useRelativeKey>false</useRelativeKey>
</level>
</timeHierarchy>
<timeWizardColumn name="start"/>
</timeWizardDimension>
<cube id="b9aceb66-c3dc-4d20-9f74-1ada8769cf75" name="Changes" description="">
<defaultFacts measureGroupName="Facts" partitioningLevelName="" partitioningType="NONE" newGeneration="true" dataTableId="c41cc2b5-1412-4da1-8e0e-3bd1b07e9d66" aggregateDataSourceFacts="false" unresolvedRowsBehavior="ERROR">
<rowFactAggregationType>ADD_ROW</rowFactAggregationType>
<measure name="# changes" aggregationType="SUM">
<rollupHierarchy></rollupHierarchy>
<dataColumn name="#changes"/>
<cellProperties></cellProperties>
<emptyIsZero>false</emptyIsZero>
</measure>
<measure name="# changes close" aggregationType="CLOSE">
<rollupHierarchy>[Time].[Time]</rollupHierarchy>
<dataColumn name="#changes"/>
<cellProperties></cellProperties>
<emptyIsZero>false</emptyIsZero>
</measure>
<links dimensionId="0c4cf980-73d9-4c42-ae47-a300421c29a2">
<viewLinks type="LAST_LEVEL">
<toColumns name="chg"/>
</viewLinks>
</links>
<links dimensionId="ed48052e-2c11-48a8-9407-c4854b163cb6">
<viewLinks type="LAST_LEVEL">
<toColumns name="phase"/>
</viewLinks>
</links>
<links dimensionId="b545bf65-ec47-4267-a4f1-a8df35096bc4">
<viewLinks type="RANGE_FROM_TO">
<toColumns name="start"/>
<toColumns name="end"/>
</viewLinks>
</links>
</defaultFacts>
<defaultFacts measureGroupName="Facts - delta" partitioningLevelName="" partitioningType="NONE" newGeneration="true" dataTableId="aea29582-84e2-4ef4-a169-5d9549141ba6" aggregateDataSourceFacts="false" unresolvedRowsBehavior="ERROR">
<rowFactAggregationType>ADD_ROW</rowFactAggregationType>
<measure name="# changes (based on delta)" aggregationType="SUM">
<rollupHierarchy></rollupHierarchy>
<dataColumn name="delta"/>
<cellProperties></cellProperties>
<emptyIsZero>false</emptyIsZero>
</measure>
<links dimensionId="0c4cf980-73d9-4c42-ae47-a300421c29a2">
<viewLinks type="LAST_LEVEL">
<toColumns name="chg"/>
</viewLinks>
</links>
<links dimensionId="ed48052e-2c11-48a8-9407-c4854b163cb6">
<viewLinks type="LAST_LEVEL">
<toColumns name="phase"/>
</viewLinks>
</links>
<links dimensionId="b545bf65-ec47-4267-a4f1-a8df35096bc4">
<viewLinks type="LAST_LEVEL">
<toColumns name="date"/>
</viewLinks>
</links>
</defaultFacts>
</cube>
<localization enabled="false"/>
<script>
<content>--
-- Automatically migrated from an old XML file definition format (v2.0.4 or before)
--
--
-- Drop all calc. members, sets and functions declared at schema/cube levels
--
DROP *
--
-- Functions
--
--
-- Sets
--
--
-- Calculated Measures/Members
--
CREATE MEMBER [#changes ITD] as Aggregate( compactSet(NULL:[Time].[Time].currentMember) , [Measures].[# changes (based on delta)] )</content>
</script>
</schemaDefinition>
</schemaFactory>
I have found a solution with regular MDX following the approach given by purple frog. Unfortunately the standard solution provided by icCube does not support the "end-of-period-interval" problem as indicated in my question.
I have rebuild the problem in enclosed icCube scheme for reference, might someone else run into a similar problem. At the end of this solution I have added the icCube schema as XML code.
1st - the data
(LEFT: data set for Ranged Dimension II - but does not work for phases, RIGHT: data set that provides the required result)
INCORRECT RESULT - the MDX based on LEFT - ranged dimension:
CORRECT RESULT - the MDX based on the RIGHT data set:
A few considerations:
- Notice that in the "CORRECT RESULT" the "1" value for 2018 Jun has been removed. This might seem unexpected but it is in line with the definition of the problem: show the value of the end of the selected period (in this case: month). And as it has phase "e" has been ended 13 June, it is empty at 30 June.
Hope you benefit from this too.
Here is the XML builder schema:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<schemaFactory revisionNumber="7">
<schemaDefinition name="Phases - ranged dimension II" description="issue description StackOverflow" group="StackOverflow" loadOnStartup="false">
<activateIncrementalLoad>false</activateIncrementalLoad>
<useUnknownMembersInFacts>false</useUnknownMembersInFacts>
<autoCleanUpTableColumns>false</autoCleanUpTableColumns>
<useFactPartitioning>false</useFactPartitioning>
<callGarbageCollector>NONE</callGarbageCollector>
<backup>NONE</backup>
<nonEmptyCachePolicy>NONE</nonEmptyCachePolicy>
<nonEmptyCacheType>REGULAR</nonEmptyCacheType>
<nonEmptyCachePersistency>MEMORY</nonEmptyCachePersistency>
<storagePolicy>DEFAULT</storagePolicy>
<hierarchyUniqueNameStyle>IncludeDimensionName</hierarchyUniqueNameStyle>
<inMemoryDS name="manual">
<memoryDataTable tableName="facts" rowLimit="-1" id="c41cc2b5-1412-4da1-8e0e-3bd1b07e9d66">
<column name="start" tableType="STRING" type="DATE" selected="true" primaryKey="false" nullObjectAsString=""/>
<column name="end" tableType="STRING" type="DATE" selected="true" primaryKey="false" nullObjectAsString=""/>
<column name="phase" tableType="STRING" type="STRING" selected="true" primaryKey="false" nullObjectAsString=""/>
<column name="chg" tableType="STRING" type="STRING" selected="true" primaryKey="false" nullObjectAsString=""/>
<column name="#changes" tableType="STRING" type="INTEGER" selected="true" primaryKey="false" nullObjectAsString=""/>
<addRowNumber>false</addRowNumber>
<stringDateConverter>d MMM, yyyy</stringDateConverter>
<stringDateConverterLocale>en</stringDateConverterLocale>
<trimStrings>true</trimStrings>
<columnSeparator>;</columnSeparator>
<commentMarker>#</commentMarker>
<dataAsString>start;end;phase;chg;#changes
1 January, 2018;1 February, 2018; a;chg001;1
1 February, 2018;5 March, 2018;b;chg001;1
5 March, 2018;20 March, 2018;c;chg001;1
20 March, 2018;20 March, 2018;d;chg001;1
20 March, 2018;3 June, 2018;e;chg001;1
</dataAsString>
</memoryDataTable>
<memoryDataTable tableName="phases" rowLimit="-1" id="b24aaebb-7ce3-42a9-bab0-a54bc4c4b896">
<column name="phase" tableType="STRING" type="STRING" selected="true" primaryKey="false" nullObjectAsString=""/>
<addRowNumber>false</addRowNumber>
<stringDateConverter></stringDateConverter>
<trimStrings>true</trimStrings>
<columnSeparator>,</columnSeparator>
<commentMarker>#</commentMarker>
<dataAsString>phase
a
b
c
d
e
</dataAsString>
</memoryDataTable>
<memoryDataTable tableName="changes" rowLimit="-1" id="8ba9aaca-0d93-49b1-851f-4f325e05bbbe">
<column name="chg" tableType="STRING" type="STRING" selected="true" primaryKey="false" nullObjectAsString=""/>
<addRowNumber>false</addRowNumber>
<stringDateConverter></stringDateConverter>
<trimStrings>true</trimStrings>
<columnSeparator>;</columnSeparator>
<commentMarker>#</commentMarker>
<dataAsString>chg
chg001
chg002
chg003</dataAsString>
</memoryDataTable>
<memoryDataTable tableName="facts - delta" rowLimit="-1" id="aea29582-84e2-4ef4-a169-5d9549141ba6">
<column name="date" tableType="STRING" type="DATE" selected="true" primaryKey="false" nullObjectAsString=""/>
<column name="phase" tableType="STRING" type="STRING" selected="true" primaryKey="false" nullObjectAsString=""/>
<column name="chg" tableType="STRING" type="STRING" selected="true" primaryKey="false" nullObjectAsString=""/>
<column name="delta" tableType="STRING" type="INTEGER" selected="true" primaryKey="false" nullObjectAsString=""/>
<addRowNumber>false</addRowNumber>
<stringDateConverter>d MMM, yyyy</stringDateConverter>
<stringDateConverterLocale>en</stringDateConverterLocale>
<trimStrings>true</trimStrings>
<columnSeparator>;</columnSeparator>
<commentMarker>#</commentMarker>
<dataAsString>date;phase;chg;delta
1 January, 2018;a;chg001;1
1 February, 2018;b;chg001;1
5 March, 2018;c;chg001;1
20 March, 2018;d;chg001;1
20 March, 2018;e;chg001;1
1 February, 2018;a;chg001; -1
5 March, 2018;b;chg001;-1
20 March, 2018;c;chg001;-1
20 March, 2018;d;chg001;-1
13 June, 2018;e;chg001;-1
</dataAsString>
</memoryDataTable>
</inMemoryDS>
<multiLevelDimension dataTableId="8ba9aaca-0d93-49b1-851f-4f325e05bbbe" isTimeDimension="false" isDefaultTimeDimension="false" isIndexingByRange="false" id="0c4cf980-73d9-4c42-ae47-a300421c29a2" name="Change">
<multiLevelHierarchy hasAllLevel="true" allLevelName="All-Level" allMemberName="All" name="Change" isDefault="true">
<level name="change" nameUnique="false" nameUniqueInParent="false" keyUnique="false" ignoreNameCollision="false">
<nameCol name="chg"/>
<orderType>BY_NAME</orderType>
<orderKind>ASC</orderKind>
</level>
</multiLevelHierarchy>
</multiLevelDimension>
<multiLevelDimension dataTableId="b24aaebb-7ce3-42a9-bab0-a54bc4c4b896" isTimeDimension="false" isDefaultTimeDimension="false" isIndexingByRange="false" id="ed48052e-2c11-48a8-9407-c4854b163cb6" name="Phase">
<multiLevelHierarchy hasAllLevel="true" allLevelName="All-Level" allMemberName="All" name="Phase" isDefault="true">
<level name="phase" nameUnique="false" nameUniqueInParent="false" keyUnique="false" ignoreNameCollision="false">
<nameCol name="phase"/>
<orderType>BY_NAME</orderType>
<orderKind>ASC</orderKind>
</level>
</multiLevelHierarchy>
</multiLevelDimension>
<timeWizardDimension isDefaultTimeDimension="false" isIndexingByRange="true" from="2018-06-01T00:00:00.000" to="2018-07-31T00:00:00.000" dataTableId="c41cc2b5-1412-4da1-8e0e-3bd1b07e9d66" unknownMemberName="" id="b545bf65-ec47-4267-a4f1-a8df35096bc4" name="Time">
<timeHierarchy hasAllLevel="true" allLevelName="All-L" allMemberName="All-M" name="Time" isDefault="true" defaultMemberName="">
<factAggregationType>MEMBER_AND_ANCESTORS</factAggregationType>
<level name="Year" type="YEAR">
<useRelativeKey>false</useRelativeKey>
</level>
<level name="Month" type="MONTH" nameFormat="">
<useRelativeKey>false</useRelativeKey>
</level>
<level name="Day" type="DAY" nameFormat="">
<useRelativeKey>false</useRelativeKey>
</level>
</timeHierarchy>
<timeWizardColumn name="start"/>
</timeWizardDimension>
<cube id="b9aceb66-c3dc-4d20-9f74-1ada8769cf75" name="Changes" description="">
<defaultFacts measureGroupName="Facts" partitioningLevelName="" partitioningType="NONE" newGeneration="true" dataTableId="c41cc2b5-1412-4da1-8e0e-3bd1b07e9d66" aggregateDataSourceFacts="false" unresolvedRowsBehavior="ERROR">
<rowFactAggregationType>ADD_ROW</rowFactAggregationType>
<measure name="# changes" aggregationType="SUM">
<rollupHierarchy></rollupHierarchy>
<dataColumn name="#changes"/>
<cellProperties></cellProperties>
<emptyIsZero>false</emptyIsZero>
</measure>
<measure name="# changes close" aggregationType="CLOSE">
<rollupHierarchy>[Phase].[Phase]</rollupHierarchy>
<dataColumn name="#changes"/>
<cellProperties></cellProperties>
<emptyIsZero>false</emptyIsZero>
</measure>
<links dimensionId="0c4cf980-73d9-4c42-ae47-a300421c29a2">
<viewLinks type="LAST_LEVEL">
<toColumns name="chg"/>
</viewLinks>
</links>
<links dimensionId="ed48052e-2c11-48a8-9407-c4854b163cb6">
<viewLinks type="LAST_LEVEL">
<toColumns name="phase"/>
</viewLinks>
</links>
<links dimensionId="b545bf65-ec47-4267-a4f1-a8df35096bc4">
<viewLinks type="RANGE_FROM_TO">
<toColumns name="start"/>
<toColumns name="end"/>
</viewLinks>
</links>
</defaultFacts>
<defaultFacts measureGroupName="Facts - delta" partitioningLevelName="" partitioningType="NONE" newGeneration="true" dataTableId="aea29582-84e2-4ef4-a169-5d9549141ba6" aggregateDataSourceFacts="false" unresolvedRowsBehavior="ERROR">
<rowFactAggregationType>ADD_ROW</rowFactAggregationType>
<measure name="# changes (based on delta)" aggregationType="SUM">
<rollupHierarchy></rollupHierarchy>
<dataColumn name="delta"/>
<cellProperties></cellProperties>
<emptyIsZero>false</emptyIsZero>
</measure>
<links dimensionId="0c4cf980-73d9-4c42-ae47-a300421c29a2">
<viewLinks type="LAST_LEVEL">
<toColumns name="chg"/>
</viewLinks>
</links>
<links dimensionId="ed48052e-2c11-48a8-9407-c4854b163cb6">
<viewLinks type="LAST_LEVEL">
<toColumns name="phase"/>
</viewLinks>
</links>
<links dimensionId="b545bf65-ec47-4267-a4f1-a8df35096bc4">
<viewLinks type="LAST_LEVEL">
<toColumns name="date"/>
</viewLinks>
</links>
</defaultFacts>
</cube>
<localization enabled="false"/>
<script>
<content>--
-- Automatically migrated from an old XML file definition format (v2.0.4 or before)
--
--
-- Drop all calc. members, sets and functions declared at schema/cube levels
--
DROP *
--
-- Functions
--
--
-- Sets
--
--
-- Calculated Measures/Members
--
</content>
</script>
</schemaDefinition>
</schemaFactory>

Multiple hierarchy in mondrian says Hierarchy not found

I have following Dimension in mondrian schema. Mondrian on creating connection says
mondrian.olap.MondrianException: Mondrian Error:Internal error: Hierarchy '[Product]' not found
<Dimension name="Product" foreignKey="item_id">
<Hierarchy hasAll="true" primaryKey="item_code" primaryKeyTable="m_item_master">
<Join leftKey="item_code" rightKey="item_code">
<Table name="m_item_master"/> <!--dummy_master--> <!--m_item_master-->
<Table name="m_item_relation"/>
</Join>
<Level name="Department" table="m_item_relation" column="department"/>
<Level name="Class" table="m_item_relation" column="category"/>
<Level name="Item" table="m_item_master" column="item_code" ordinalColumn="item_code" nameColumn="name" uniqueMembers="true" type="Numeric"/>
</Hierarchy>
<Hierarchy name="Base Item" hasAll="false" primaryKey="item_code" primaryKeyTable="m_item_master">
<Join leftKey="item_code" rightKey="item_code">
<Table name="m_item_master"/> <!--dummy_master--> <!--m_item_master-->
<Table name="m_item_relation"/>
</Join>
<Level name="Department" table="m_item_relation" column="department" captionColumn="department"/>
<Level name="Item" table="m_item_master" column="item_code" ordinalColumn="item_code" nameColumn="name" uniqueMembers="true" captionColumn="name" type="Numeric"/>
<Property name="Price" table="m_item_master" column="price" />
</Hierarchy>
</Dimension>
I am using Mondrian-4.0.0-SNAPSHOT version and tried the same with latest mondrian 4.2.0.0-204 version as well.
Note:
Moreover I am getting this Error during mondrian connection creation itself. So it doesn't concern with any MDX query passed to it.
Ok. This is the what the mistake I found. For the clarification, Mondrian do support multiple hierarchy, but to the above schema we seems to have a different problem with the associated roles.
<Role name="myrole">
<SchemaGrant access="none">
<CubeGrant cube="Transaction" access="all">
<HierarchyGrant hierarchy="[Product]" access="custom" rollupPolicy="partial">
<MemberGrant member="[Product].[Cottage Foods]" access="all"/>
<MemberGrant member="[Product].[Vegetables]" access="all"/>
....
</HierarchyGrant>
....
</CubeGrant>
</SchemaGrant>
</Role>
In the above role, though the default hierarchy takes the name of the dimension in mondrian, we have to specify them as [Dimension.Hierarchy] in roles but not just Hierarchy name if you have multiple hierarchy within the Dimension. In our case, it should be as below.
<Role name="myrole">
<SchemaGrant access="none">
<CubeGrant cube="Transaction" access="all">
<HierarchyGrant hierarchy="[Product.Product]" access="custom" rollupPolicy="partial">
<MemberGrant member="[Product.Product].[Cottage Foods]" access="all"/>
<MemberGrant member="[Product.Product].[Vegetables]" access="all"/>
....
</HierarchyGrant>
....
</CubeGrant>
</SchemaGrant>
</Role>
This solves the above problem.

mdx query is taking for more time than sql

i have converted sql analysis to mdx analysis and found that mdx is far more expensive in term of execution time than sql. below is the sql which i am trying to convert to mdx
select inc.incident_id,inc.incident_start_time, inc.incident_end_time,inc_type.incident_type,inc.incident_desc,st_x(inc.the_geom) as incident_lon, st_y(inc.the_geom) as incident_lat,inc_type.class_name as incident_class, inc_type.incident_image ,fir.modus_operandi, fir.fir_status, fir.fir_serial_no as fir_id from analyst_mdx.incident as inc join analyst_mdx.incident_types as inc_type on inc.incident_type = inc_type.incident_type_id left outer join analyst_mdx.fir_details as fir on inc.fir_no = fir.fir_no join analyst_mdx.district on (st_contains(district.the_geom, inc.the_geom) and district.district_id=1) where inc.incident_type in ('10','8','14','11','5','9','19','21','6','7','16','3','4','12','20','13','1','2','23','17','18') and ((inc.incident_start_time between '2012-01-29T00:00:00' and '2014-12-29T23:59:59')) order by incident_start_time, incident_end_time
and this is the fact tables are interconnected
now let me show you the mdx which i have made
with member [Measures].[incident_type] as '[incident].CurrentMember.Properties("incident_type")'
member [Measures].[incident_desc] as '[incident].CurrentMember.Properties("incident_desc")'
member [Measures].[incident_class] as '[incident].CurrentMember.Properties("incident_class")'
member [Measures].[incident_image] as '[incident].CurrentMember.Properties("incident_image")'
member [Measures].[modus_operandi] as '[incident].CurrentMember.Properties("modus_operandi")'
member [Measures].[fir_status] as '[incident].CurrentMember.Properties("fir_status")'
member [Measures].[fir_id] as '[incident].CurrentMember.Properties("fir_id")'
member [Measures].[date_start_time] as '[incident].CurrentMember.Properties("date_start_time")'
member [Measures].[the_geom] as '[incident].CurrentMember.Properties("the_geom")'
member [Measures].[date_end_time] as '[incident].CurrentMember.Properties("date_end_time")'
member [time].[newtime] as 'Aggregate({([time].[all periods].[2012].[4].[15] : [time].[all periods].[2012].[4].[30]),([time].[all periods].[2012].[5]:[time].[all periods].[2012].[12]) ,([time].[all periods].[2013]),([time].[all periods].[2014].[1] : [time].[all periods].[2014].[6]),([time].[all periods].[2014].[7].[1] : [time].[all periods].[2014].[7].[15])})'
select {[Measures].[incident_type], [Measures].[incident_desc], [Measures].[incident_class],[Measures].[incident_image], [Measures].[modus_operandi], [Measures].[fir_status],[Measures].[fir_id], [Measures].[the_geom], [Measures].[date_start_time],[Measures].[date_end_time], [Measures].[incident_count]} ON COLUMNS,
NON EMPTY Filter([incident].[incident_id].Members, ST_Contains([district].[all district].[1].Properties("the_geom"),[incident].CurrentMember.Properties("the_geom"))) ON ROWS
from [pin_mapping]
where ([time].[newtime])
maximum record for a table is 65 thousand, sql executes in not more than 3 seconds and mdx takes more than 10 minutes. my entire olap concepts fails with it. can anyone explain me where i am going wrong ?
this is the cube that i am using...
<Schema name="analyst_haryana">
<Cube name="pin_mapping" cache="true" enabled="true">
<Table name="pin_mapping_fact_table" schema="analyst_mdx"></Table>
<Dimension type="StandardDimension" foreignKey="incident_id" name="incident">
<Hierarchy hasAll="true" allMemberName="all incident" primaryKey="incident_id">
<Table name="incident" schema="analyst_mdx"> </Table>
<Level name="incident_id" column="incident_id" type="Numeric" uniqueMembers="true" levelType="Regular" hideMemberIf="Never">
<Property name="the_geom" column="the_geom" type="Geometry"></Property>
<Property name="incident_type" column="incident_desc" type="String"></Property>
<Property name="incident_desc" column="incident_desc" type="String"></Property>
<Property name="fir_status" column="fir_status" type="String"></Property>
<Property name="incident_image" column="incident_image" type="String"></Property>
<Property name="modus_operandi" column="incident_desc" type="String"></Property>
<Property name="incident_class" column="incident_desc" type="String"></Property>
<Property name="date_start_time" column="date_start_time" type="String"></Property>
<Property name="date_end_time" column="date_end_time" type="String"></Property>
</Level>
</Hierarchy>
</Dimension>
<Dimension type="TimeDimension" foreignKey="time_id" name="time">
<Hierarchy hasAll="true" allMemberName="all periods" primaryKey="time_id">
<Table name="aux_dates" schema="analyst_mdx"></Table>
<Level name="year" column="the_year" type="Numeric" uniqueMembers="true" levelType="TimeYears" hideMemberIf="Never"></Level>
<Level name="quarter" column="the_quarter" type="String" uniqueMembers="false" levelType="TimeQuarters" hideMemberIf="IfParentsName"></Level>
<Level name="month" column="the_month" type="Numeric" uniqueMembers="false" levelType="TimeMonths" hideMemberIf="IfParentsName"></Level>
<Level name="day" column="the_day" type="Numeric" uniqueMembers="false" levelType="TimeDays" hideMemberIf="IfParentsName"></Level>
</Hierarchy>
</Dimension>
<Dimension type="StandardDimension" foreignKey="district_id" name="district">
<Hierarchy hasAll="true" allMemberName="all district" primaryKey="district_id">
<Table name="district" schema="analyst_mdx"></Table>
<Level name="district_id" column="district_id" type="Numeric" uniqueMembers="true" levelType="Regular" hideMemberIf="IfParentsName">
<Property name="the_geom" column="the_geom" type="Geometry"></Property>
</Level>
</Hierarchy>
</Dimension>
<Dimension type="StandardDimension" foreignKey="incident_type_id" name="incident_type">
<Hierarchy hasAll="true" allMemberName="all incident _types" primaryKey="incident_type_id">
<Table name="incident_types" schema="analyst_mdx"></Table>
<Level name="incident_type_id" column="incident_type_id" type="Numeric" uniqueMembers="true" levelType="Regular" hideMemberIf="Never"></Level>
</Hierarchy>
</Dimension>
<Dimension type="StandardDimension" foreignKey="fir_serial_no" name="fir_details">
<Hierarchy hasAll="true" allMemberName="all status" primaryKey="fir_serial_no">
<Table name="fir_details" schema="analyst_mdx"></Table>
<Level name="fir_status" column="fir_status" type="String" uniqueMembers="false" levelType="Regular" hideMemberIf="Never"></Level>
</Hierarchy>
</Dimension>
<Measure name="incident_count" column="incident_count" datatype="Numeric" aggregator="count" visible="true"></Measure>
</Cube>
</Schema>
Well, not exactly sure, since I don't have the execution plans, but here goes nothing..
You have a well tuned SQL query on top which is doing set computation, which SQL Server is good at. And since the size of table is relatively small, it is bound to be fast. On the other hand, in the MDX query, you are actually doing cell-by-cell computation(due to use of CURRENTMEMBER function. The analysis engine sucks at it! Thus it is bound to be slow.
You are using the NON EMPTY function, which basically iterates through each and every row and filters out the EMPTY ones. This adds to the overhead on the engine. Run the query by removing the NON EMPTY clause, and see if it brings down the execution time(Though, I have observed that sometimes NON EMPTY clause actually improves rendering time)
The cube design must be revisited here. All the calculated members must be tried to be put as attributes of the dimensions involved, if possible.
Enable the mondrian slow sql query log (done in log4j.xml) and see which query is the issue.
See if it is one query, or simply that mondrian is executing 1000's.
If the latter review your approxRowCount options in the schema as well as uniqueMembers options. Possibly post the schema and results of the above changes so we can understand more. There's also the (deprecated) highcardinality option.

Using the Propel ORM, how would one delete all related records of an object?

I have a pretty simple Propel question. I'm storing leads in a database. Those leads have one or more community interests. The tables I'm using are named, 'lead', 'community', and a 'lead_communities' join table. What's the best way to delete all of a lead's community interests?
Here are some more details. The Propel schema looks like this:
<table name="community">
<column name="id" type="INTEGER" required="true" primaryKey="true" autoIncrement="true" />
<column name="name" type="VARCHAR" size="255" />
<column name="address" type="VARCHAR" size="255" />
etc...
<table name="lead_communities">
<column name="id" type="INTEGER" required="true" primaryKey="true" autoIncrement="true"/>
<column name="lead_id" type="INTEGER" />
<column name="community_id" type="INTEGER" />
<column name="created_date" type="DATE" size="4" />
<foreign-key foreignTable="community" refPhpName="Lead_Communities">
<reference local="community_id" foreign="id"/>
</foreign-key>
<foreign-key foreignTable="lead" refPhpName="Lead_Communities">
<reference local="lead_id" foreign="id"/>
</foreign-key>
</table>
<table name="lead">
<column name="id" type="INTEGER" required="true" primaryKey="true" autoIncrement="true"/>
<column name="salutation" type="VARCHAR" size="20" />
<column name="first_name" type="VARCHAR" size="255" defaultValue="" />
<column name="last_name" type="VARCHAR" size="255" defaultValue="" />
<column name="email" type="VARCHAR" size="255" defaultValue="" />
etc..
Here's how I select the lead from the database:
$lead = LeadQuery::create()->filterByEmail($enauk)->findOne();
So, what I hope to do is something like:
$lead->deleteLeadCommunities();
Well, the easiest way I can think of without any other context is simply doing a query on the join table with a delete() call:
$numDeleted = LeadCommunitiesQuery::create()
->filterByLead($lead)
->delete();
Just to be clear, there is no generated method like what you want (deleteLeadCommunities), but you could always write it for convenience, and replace $lead in my example code with $this. So inside Lead.php:
public function deleteLeadCommunities() {
return LeadCommunitiesQuery::create()
->filterByLead($this)
->delete();
}