Power BI lesson: multiple tables
Original diagram created for this blog.
Why separate tables?
Separate tables reduce repeated text. Sales can store ProductId while Products stores ProductName and Category.
Connect them
- Load both tables.
- Open Model view.
- Connect Products[ProductId] to Sales[ProductId].
- Check that the Products key is unique.
- Use Category from Products with Amount from Sales.
Practice
Create Sales and Products CSV files, connect them, and compare a category chart with a manual total.
Worked example: products and sales
Use Home → Enter data to create Products with three rows: (1, Notebook, Stationery), (2, Pen, Stationery), (3, Backpack, Bags). The columns are ProductId, ProductName and Category. Create Sales with ProductId and Amount rows: (1, 1200), (2, 400), (1, 900), (3, 1600). ProductId repeats in Sales because a product can be sold more than once.
- In Model view, connect
Products[ProductId]toSales[ProductId]. The relationship should be one-to-many (1:*). - Create
Total Sales = SUM(Sales[Amount]). - Build a bar chart using
Products[Category]and[Total Sales]. Stationery should be 2500; Bags should be 1600.
If each category shows 4100, the relationship may be missing or inactive. If Power BI refuses the one side, check for duplicate ProductId values in Products. Keep ProductId types the same in both tables. This simple model is easier to maintain than copying a product name into every sale row.
Return to the Power BI hub · Microsoft relationship documentation
No comments:
Post a Comment
Please do not enter any spam link in the comment box.