Pivot Table Issues

How to Build Data Model Relationships for Product and Service Line Data in Excel

Maira MehtabMaira Mehtab Nov 10, 2026 868 views

Question details

The user needs to establish reliable data model relationships for Sales and COGS fact tables when the Product ID is not a unique key and the Service Line affects data aggregation.

How to Build Data Model Relationships for Product and Service Line Data in Excel
Product
Excel Power Pivot
Device & OS
not provided
Scenario
Creating an advanced data model combining Sales and Cost of Goods Sold (COGS) tables where transactions depend on both the Product ID and the specific Service Line.
Observed behavior
Without proper relationships handling both fields, aggregations fail, often resulting in the total COGS for a product being inaccurately repeated across every service-line row in the Pivot Table.
Before you start

Ensure your raw Sales and COGS data tables are formatted as official structured tables and that the Power Pivot add-in is enabled in your spreadsheet application.

Solution 1Recommended

Use a Star Schema with Shared Dimensions

Create dedicated, separate dimension tables for Product and Service Line to properly filter both fact tables without ambiguity.

A star schema is the most robust and scalable way to structure a data model. By abstracting the unique attributes into central dimension tables, you avoid many-to-many relationship conflicts between your Sales and COGS fact tables.

1
Create Dimension Tables

Extract a list of unique Product IDs into a new 'Product Dimension' table, and unique Service Lines into a 'Service Line Dimension' table.

2
Add to Data Model

Import both your newly created dimension tables and your existing Sales and COGS fact tables into the Power Pivot Data Model.

3
Switch to Diagram View

Open the Data Model window and click on 'Diagram View' in the Home tab to visualize your tables.

4
Establish Relationships

Click and drag the Product ID field from the Product Dimension table to the Product ID field in both fact tables. Repeat this process for the Service Line field, creating one-to-many relationships from the dimensions to the facts.

Use a Star Schema with Shared Dimensions
Best Practice: Using a star schema ensures that any filters applied in your Pivot Table will correctly flow downhill to both the Sales and COGS tables, resulting in accurate totals.
Free Microsoft Office alternative

Need a Lightweight Alternative for Data Analysis? Try WPS Office

While advanced Power Pivot DAX functions like TREATAS are specific to Microsoft Excel, WPS Office provides a highly compatible, free, and intuitive Spreadsheet tool. It easily handles standard Pivot Tables, composite key concatenation, and comprehensive data analysis without the heavy resource requirements.

  1. 1. Download WPS Office: Visit the official WPS website and download the free desktop application.
  2. 2. Open Your Data: Launch WPS Spreadsheet and open your existing .xlsx files seamlessly.
  3. 3. Analyze Data: Use built-in Pivot Tables and concatenation formulas to aggregate and manage your sales and product data efficiently.
Free and lightweight complete Office suiteSeamless compatibility with Microsoft Excel (.xlsx) formatsRobust standard Pivot Table and data aggregation featuresFamiliar user interface for immediate productivity
microsoft office alternative - wps office

Frequently Asked Questions

Why are my COGS totals repeating on every service-line row in my Pivot Table?

This occurs when your data model lacks a relationship that filters by Service Line. Without that relationship, the Pivot Table loses the filter context, causing it to display the grand total for the product across all service-line rows.

What is a composite key in a data model?

A composite key is a single column created by merging two or more data points (like Product ID and Service Line). It is used to generate a unique identifier for a row, enabling a standard one-to-many relationship when individual columns are not unique.

Can I use DAX to create relationships without changing my source tables?

Yes. DAX functions like TREATAS allow you to build 'virtual relationships' by passing filters directly within a measure's calculation, removing the need to add new physical columns to your tables.

What is the advantage of a star schema over a single flat table?

A star schema minimizes redundant data and optimizes processing speed. By placing descriptive attributes in central lookup tables (dimensions) and keeping measurable events in fact tables, your Pivot Tables can filter related data much more efficiently.