Ravindra BagaleCourses & study guides Track your progress

Guides

Power Pivot Relationships: One PivotTable from Two Tables

Ravina's Sales table has Product ID and Qty. Her Products table has the product name, category and price. To see revenue by category she would normally add three VLOOKUP columns to Sales. With the Data Model she draws one line between the two Product ID columns and builds the PivotTable straight away.

The Data Model stores several tables inside the workbook. A relationship tells Excel that Sales[Product ID] matches Products[Product ID]. Power Pivot is the window where you see and manage those tables, relationships and DAX measures.

Download the practice file (power-pivot-relationships.xlsx)

Excel file, 8 KB. It has the sample data used below. All numbers in this workbook are fictional teaching data, not real company figures.

Quick answer

  1. Make both lists Excel Tables named Sales and Products.
  2. Click in Sales, Insert > PivotTable, tick Add this data to the Data Model, click OK.
  3. In the PivotTable Fields pane click All, so both tables show.
  4. Tick Products > Category and Sales > Qty. Click Create when Excel asks for a relationship, or create it in Data > Relationships.
  5. For revenue, add a measure (see below).
Revenue := SUMX(Sales, Sales[Qty] * RELATED(Products[Price]))

The two tables

DateProduct IDCityQty
02-09-2026P1Pune10
03-09-2026P2Nashik4
05-09-2026P1Nashik6
09-09-2026P3Pune3
12-09-2026P2Pune8
18-09-2026P3Nagpur5
21-09-2026P1Nagpur7
27-09-2026P2Kolhapur2
Product IDProductCategoryPrice
P1Milk 1LDairy56
P2Paneer 200gDairy90
P3BreadBakery40

Create the relationship in Diagram View

  1. Turn on Power Pivot once: File > Options > Add-ins > Manage: COM Add-ins > Go, tick Microsoft Power Pivot for Excel.
  2. Click Power Pivot > Manage.
  3. Click Home > Diagram View.
  4. Drag Product ID from Sales onto Product ID in Products.
  5. A line appears: many Sales rows (*) point to one Products row (1).

Add a revenue measure

  1. In the PivotTable Fields pane, right-click the Sales table and choose Add Measure.
  2. Name it Revenue.
  3. Type the formula =SUMX(Sales,Sales[Qty]*RELATED(Products[Price])).
  4. Choose Currency format and click OK.
  5. Tick Revenue. The PivotTable shows revenue by category.
CategoryQtyRevenue
Bakery8₹320
Dairy37₹2,548
Grand Total45₹2,868

The practice file checks these numbers with normal formulas: Dairy revenue is =SUMPRODUCT((Sales[Product ID]="P1")*Sales[Qty])*56+SUMPRODUCT((Sales[Product ID]="P2")*Sales[Qty])*90 = 23 × 56 + 14 × 90 = 2548.

Rules for good relationships

  • The lookup table (Products) must have each Product ID only once.
  • Both columns must have the same data type.
  • Put descriptions (category, price) in the lookup table, and events (date, qty) in the fact table. This shape is called a star schema.
  • Use a measure for totals that multiply columns from two tables; you cannot drag Price into Values and get revenue.

Ravindra Bagale's Tip

If the PivotTable shows the same number on every row, the relationship is missing or points the wrong way. Open Diagram View and check the line goes from Sales (many) to Products (one).

Practice task

  1. Open the practice file with the Sales and Products tables.
  2. Create a PivotTable from Sales with Add this data to the Data Model ticked.
  3. Create the relationship on Product ID.
  4. Add the Revenue measure and put Category in Rows.
  5. Check Dairy shows ₹2,548 and Bakery ₹320, the same as the check cells on the Sales sheet.

Frequently asked questions

Do I need Power Pivot to use relationships?

No. Data > Relationships and the PivotTable's Add this data to the Data Model work without opening Power Pivot. Power Pivot adds Diagram View and easier measure editing.

Why can I not create the relationship?

Usually the lookup column has duplicates or blanks, or the two columns have different data types.

Is the Data Model the same as Power BI?

It uses the same engine and DAX language. A Data Model workbook can be imported into Power BI Desktop.

Which Excel versions have Power Pivot?

Microsoft 365 and Excel 2016 and later on Windows. It is not available in Excel for the web.