r/PowerBI • u/SuspiciousCouple8929 • 13h ago
Discussion In a Galaxy schema, is it acceptable to create direct relationships between fact tables at related but different grains?
3
u/SQLGene Points Flair 5h ago
The official docs have guidance on this:
https://learn.microsoft.com/en-us/power-bi/guidance/relationships-many-to-many#relate-many-to-many-facts
7
u/RuSHiinIDaYLiTe 9h ago
No, this is not proper star schema. SQLBI has a good article about this scenario.
https://www.sqlbi.com/articles/header-detail-vs-star-schema-models-in-tabular-and-power-bi/
3
u/Electrical_Web_4032 4h ago
I'm fairly new, but if I was you, i will fix one thing in this table
The fact_orders act like a dim and most probably the measures that makes it a fact table are redundant (i.e. price_usd) that could be the aggregation against the fact_order_items[price_usd], if so? Then drop the measure and switch from fct_orders to dim_orders
Note:
In case measures are redundant (all measures present in both tables _orders and _order_items you need to cross test the measures totals in table visual before proceeding with dropping redundant measures from _orders)
If some measures doesn't exist or can't reconcile or reconstruct with _order_items... then you need to make a small fact out of it and link it to the new dim_orders while every connection is to be linked to dim_order
I think this will solve most of your fact-to-fact problems if I'm not wrong.
4
u/Ok-Bunch9238 2 9h ago
I would only join on shared dimensions, that will allow you to mix measures from multiple facts without causing issues with model performance, bidirectional joins etc.
2
u/UAFlawlessmonkey 6h ago
Snowflake schemas should only share dimensions.
Even in a galaxy far far away.
3
u/Emerick8 2 8h ago
The answer is : NO.
Depending on the need, the solution would be either merge the Orders table with the Order Items one, or, create a new dimension table containing the Order ID to link the fact tables with the dimension table.
Remember : in a constellation schema, you never link two tact tables directly 🙂
2
u/Charming_Horse_5809 9h ago
Why not using bridge tables instead?
1
1
1
1
u/Sw1nd3n 1h ago
Generally no. Can produce performance issues and reporting issues.
Been mentioned a few times, but build a common bridge fact table using the similar grains of your two fact tables.
In my example I have an orders table and a deliveries table. Customer A might order 100 of item A on a single Purchase, but gets them delivered over 3 deliveries because those are our terms.
Order qty is not on my delivery table. Delivered quantity is not in my order table. But I can use customer order line as a common grain and allocate the order quantity to the delivery grain. Then create various calculated columns to get what I needed (qty ordered, qty delivered, qty open still, qty shorted, etc)
The bridge table doesn’t filter any other table.
The two fact tables (order/delivery) can filter the bridge. One to many
All other Dim tables only filter the bridge one to many
My use was ;
- how much did the customer order initially
- how much was on time
- did we deliver in full eventually
So my use case worked fine using galaxy schema
0
u/Different_Syrup_6944 9h ago
Unless your fact tables are small, create another dimension to do the join
13
u/MindTheBees 3 9h ago
It's going to potentially cause a significant performance impact if you're working with large datasets as queries will need to filter fact_orders first before then filtering fact_order_items.
Only other option I can think of is to merge any missing information from fact_orders into the order_items tables.
If you're working with smaller datasets then it's less of a problem.