Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
datadonuts
Advocate II
Advocate II

Optimal Data Modelling for Order Headers and Order Lines

Hi community,

 

In almost all of my projects I came across databases, that contains separate tables for headers and details / lines e.g. Order_Heads contains OrderID, CustomerID and OrderDate, while Order_Lines contains the details of each order like OrderID, Order_line_ID, product_ID, quantity. That’s a very common scenario and I deal with them in different ways, depending on the business case, the KPIs and the associated dim_tables.

 

On way of course is to model them as separate tables and build a relationship on the OrderID. In complex models, that often becomes a challenge, where I have to go into bi-directional relationships, which I don’t feel are optimal.

 

The second way is to merge them together (e.g. via Power Query) to get one big order table, containing the order information on the line granularity. That eases the data model but comes with the downside, that certain DAX becomes a bit complex and slow as well.

 

A third way – I call it hybrid – is to aggregate the order line table on certain figures like sum of sales, order quantity, no of products, last order date ect. and then merge that to the order header table. That works like option one plus getting more information into the header table but unfortunately loosing a lot of detail information for instance about the products, which are on the order line level.

 

I studied Bhavik Merchants book “Performance Best Practices” but unfortunately, he is not mentioning this scenario, even its very common in the real business world.

 

So I am wondering, is there a recommended or optimal way to handle that challenge. How do you do that in your projects?

 

  1. Keep them separated with a relationship
  2. Merge them into one table
  3. Another method

 

I am glad to hear from you and discuss further.

Data model order head order line.png

1 REPLY 1
amitchandak
Super User
Super User

@datadonuts , My Take

Ideally merged table should be able to solve the purpose. For header-level data we can use measure like

Sum of header discount  = Sumx(Summarize(Combined, Combined[Order Header id], [Header Discount Value]) ,[Header Discount Value] )

 

But some time model is more complex and you need the header as a dimension, in that case, you need both merged and header as a dimension. Especially when need to ignore the selected filter on header

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.