0
0
Power BIbi_tool~10 mins

Data model best practices in Power BI - Cell-by-Cell Formula Trace

Choose your learning style9 modes available
Sample Data

Sample data showing Products and Sales tables with keys to demonstrate data model relationships.

CellValue
A1ProductID
B1ProductName
C1CategoryID
D1CategoryName
E1SalesID
F1ProductID
G1Quantity
H1SalesDate
A2101
B2Apple
C21
D2Fruits
E25001
F2101
G210
H22024-06-01
A3102
B3Banana
C31
D3Fruits
E35002
F3102
G35
H32024-06-02
A4201
B4Carrot
C42
D4Vegetables
E45003
F4201
G47
H42024-06-01
Formula Trace
SUMX(RELATEDTABLE(Sales), Sales[Quantity])
Step 1: RELATEDTABLE(Sales) for ProductID 101
Step 2: SUMX(related sales rows, Sales[Quantity])
Step 3: RELATEDTABLE(Sales) for ProductID 102
Step 4: SUMX(related sales rows, Sales[Quantity])
Step 5: RELATEDTABLE(Sales) for ProductID 201
Step 6: SUMX(related sales rows, Sales[Quantity])
Cell Reference Map
Products Table       Sales Table
+----+------------+    +-------+----------+----------+------------+
| A1 | B1         |    | E1    | F1       | G1       | H1         |
|----|------------|    |-------|----------|----------|------------|
| 101| Apple      |    | 5001  | 101      | 10       | 2024-06-01 |
| 102| Banana     |    | 5002  | 102      | 5        | 2024-06-02 |
| 201| Carrot     |    | 5003  | 201      | 7        | 2024-06-01 |
+----+------------+    +-------+----------+----------+------------+
The Products table has ProductID as key. The Sales table references ProductID to link sales to products. The formula uses this relationship.
Result
+------------+----------------+---------------------+
| ProductID  | ProductName    | Total Quantity Sold  |
|------------|----------------|---------------------|
| 101        | Apple          | 10                  |
| 102        | Banana         | 5                   |
| 201        | Carrot         | 7                   |
+------------+----------------+---------------------+
The result shows total quantity sold per product by summing related sales quantities using the data model relationship.
Sheet Trace Quiz - 3 Questions
Test your understanding
What does RELATEDTABLE(Sales) do in the formula?
AFinds all sales rows matching the current product's ProductID
BSums all sales quantities in the Sales table
CFilters products by category
DReturns the product name for each sale
Key Result
Use RELATEDTABLE to get related rows from another table, then SUMX to sum values over those rows.