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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
evigil24
Regular Visitor

How to design a data model to compare orders price vs cost in a star schema?

I'm struggling triying to make a star schema from a set of tables with different origins, two SQL databases, Excel files and CSV reports, it's a bit of a puzzle.

 

The initial tables that they provide me are set like this:


1.png

 

The important points of this set of tables are:

 

  • In Products table IdProduct is not unique, because one product can be make with one type of machine in factory A, and another type of machine in factory B, so it's one row for every Factory/Machine/IdProduct combination.
  • The OrderItems table has mixed rows with materials and products, so you have all the products in the Order and all the materials used in each product of the same Order.
  • The cost of the material changes daily and is updated in the system from where I get the OrderItems table.
  • The delivery cost is different for each order.
  • The packaging and fix costs are updated once a week.
  • The product price changes from order to order (it is set taking into account the client, day and size of the order).

I got to this model dividing the OrderItems in products and costs (materials), and joining with them the fixed costs and the packaging costs, I haven't joined the delivery costs, but i end up with two fact tables and a snowflake schema:

 

2.png

 

 

I am thinking in Region, Factory, Machine, Date, Product, and a compound of cost concepts (materials, fixed costs, etc.) as dimensions, and the total amounts and quantities as facts. This to compare the total sales to the total costs around the different dimensions.
 

I just wanna know if this is the correct path or there is a better way, I tried to search more about the subject but the case is too specific so I get nothing.

 

Thanks in advance for your answers.

1 REPLY 1
AllisonKennedy
Super User
Super User

@evigil24  What's the end goal of this report? With the complexities of your data model you'll have many different relationship options, as well as filter options, so need to understand the requirements first. 

 

https://excelwithallison.blogspot.com/search?q=it%27s+complicated

 

For example, I'd say you want to combine Factory/Machine/IdProduct or at least Factory/Product to create a Unique key in your Product table, but your diagram doesn't list all the columns so I'm not sure if that will work?


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.