[Mondrian] FW: Mondrian issues with date and fact table columns
julianhyde at speakeasy.net
Tue Jul 10 05:06:02 EDT 2007
Somita Arora wrote:
Is it possible to perform calculations on fact table columns without
applying any aggregator on measure.
Eg. We want to calculate the sale amount on each record in fact table using
the columns as 'qty' * 'price' where 'qty' and 'price' exist as columns in
The problem is how do we specify this calculation in schema without using an
aggregator. We did see post on this at
&highlight=fact+aggregator , but would like an approach that didn't involve
a code modification.
I don't know whether you saw this, at
Rather than coming from a column, a measure can use a
reader, or a measure can use a SQL expression to calculate its value. The
measure "Promotion Sales" is an example of this.
< <http://mondrian.pentaho.org/documentation/schema.php#XML_Measure> Measure
name="Promotion Sales" aggregator="sum" formatString="#,###.00">
< <http://mondrian.pentaho.org/documentation/schema.php#XML_SQL> SQL
(case when sales_fact_1997.promotion_id =
0 then 0 else sales_fact_1997.store_sales end)
</ <http://mondrian.pentaho.org/documentation/schema.php#XML_SQL> SQL>
In this case, sales are only included in the summation if they correspond to
a promotion sales. Arbitrary SQL expressions can be used, including
subqueries. However, the underlying database must be able to support that
SQL expression in the context of an aggregate. Variations in syntax between
different databases is handled by specifying the dialect in the SQL tag.
Those values will still be aggregated. I can't think how it could possibly
be meaningful to use values from the fact table without aggregating them,
because any given cell might have more than one row from the fact table.
1. The mondrian 2.3.2 allows 'date' type for 'type' attribute in level.
Is it possible to apply date manipulations on such types. Eg. Finding date
differences between two member values of type date. We get 0 as result value
when we apply a difference of these values. This feature would also be
useful if we have to find difference between current date and a date member.
This query is also posted on forums as
Mondrian's support for the date datatype is not very complete. First, I
would not be surprised if there were bugs loading date columns from SQL into
memory. Second, no operators are defined which work on dates. You should be
able to define UDFs so you can manipulate dates in MDX; for example, you
might implement a Date_Subtract(<Date>, <Date>) returns <Numeric> operator
which returns the number of days between two dates.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Mondrian