Is it possible to merge 2 facts tables to create a cube in a Mondrian schema example the case of sales and cost ?
It is usual to have both sales and cost measures in one fact table and add them both as measures to one cube.
If you cannot have them both in the same fact table, they need to have common dimension(s), so they can be joined together in Virtual Cube (up to Mondrian 3.8). Time dimension is usual:
DHW
date_key, ..., sales
date_key, ..., cost
date_key, day_of_month, month, year, ...
Mondrian OLAP schema
dim_date
, primary key column date_key
, level year year
, level month ...fact_sales
, dimension [Date] usage date_key
, measure sales
fact_sales
, dimension [Date] usage date_key
, measure cost
[Date]
, virtual cube measure [Sales.sales]
, virtual cube measure [Cost.cost]
If you can use Mondrian 4 you can specify the exact SQL statement that should be executed to retrieve data for fact table. Therefore you can do the join on the database level, like below:
<PhysicalSchema>
<Query alias="FACT">
<ExpressionView>
<SQL dialect="generic">
select f.*, f2.measure_2 from FACT f INNER JOIN FACT2 f2 ON f.id = f2.fact_id
</SQL>
</ExpressionView>
</Query>
</PhysicalSchema>
See the full example here: http://thejavatar.com/mondrian-4-in-pentaho-bi-server/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With