Forum Discussion
Order / invoice data modelling
I've always struggled with order and invoice tables. My data has four important fact tables:
Order line details
Order header
Invoice line details
Invoice header
Some of the data in the header tables is redundant but every table contains enough to be too useful to skip out. To make life easier... If I could denormalise these into one table it'd be wonderful but that seems more complicated in other ways. You have several hurdles:
- orders split over multiple invoices
- invoices with no order data (eg. refunds)
- actual order lines split over multiple invoices
- potentially multiple orders per invoices (though I don't think this occurs in my data)
I've settled on just denormalising into two tables:
Orders
Invoices
Working with just the invoices table is easy... Everything is finalised and easy to make relationships and measures from. Orders on the other hand is a pain. I'm not sure how I should relate this table to the others. Here's what I have been using recently:
Most of my work was done just using the invoices table previously but now I'm using that orders table more and more (calculating complete/incomplete orders, time to completion, etc).
The problems arise when there isn't an invoice for an order. What is the best way to get around this? I started using LOOKUPVALUE to pull item and customer information... I've had to make all the filtering single direction though (it seems to interfere and I don't know why, I thought LOOKUPVALUE was meant to ignore relationships). I'm not sure if this is the best way.
6 Replies
- v-qiuyu-msftCommunity Support
The problems arise when there isn't an invoice for an order. What is the best way to get around this? I started using LOOKUPVALUE to pull item and customer information... I've had to make all the filtering single direction though (it seems to interfere and I don't know why, I thought LOOKUPVALUE was meant to ignore relationships). I'm not sure if this is the best way.Hi emarc1,
If this is no invoice record for the order, which result you want? Can you clarify it?
It would be better if you could share some sample data and show desired results for our analysis.
Best Regards,
Qiuyun Yu- emarc1Advocate II
Thank you for your reply v-qiuyu-msft.
Scenario:
- An order is placed and appears in the 'orders' table.
- The 'order' table contains the customer and item codes.
- This order has not yet been invoiced yet so there is not a line in the 'invoices' table with a related order number.
- Therefore, in this data model, there is no relationship between this row of the 'orders' table and the 'customers' and 'items' dimension tables.
What is the best way to get the customer and item dimensions for this order? Is a better data model structure possible?
To get around this (for now), I have used LOOKUPVALUE but it doesn't work unless I turn off some bi-directional filtering. Is that normal? Why does LOOKUPVALUE get affected by filtering?
- v-qiuyu-msftCommunity Support
Hi emarc1,
You can follow these two links to do data modeling:
https://www.red-gate.com/simple-talk/sql/bi/power-bi-data-modelling/
https://powerbi.microsoft.com/en-us/documentation/powerbi-desktop-create-and-manage-relationships/
Looupvalue() function should work well with both cross filter. If you don't turn off it, is there any error throws out when you use Lookupvalue() function?
Best Regards,
Qiuyun Yu