How do I calculate a margin$ field in pivot table?

oliver fortes 0 Reputation points
2025-11-25T13:14:26.8433333+00:00

I have two pivot tables, one contains units sold and unit price, the other contains the margin% agreed with a supplier.

User's image

User's image

I'm trying to create a calculated MARGIN$ column in the top table, but I can't seem to write the formula correctly.

I know it's basically Unit Price * Negotiated Price, but every time I think I've written it correctly, I get this:

User's image

Any help would be most appreciated, been sat staring at this for hours now.

Microsoft 365 and Office | Excel | For home | Windows
{count} votes

1 answer

Sort by: Most helpful
  1. Francisco Montilla 23,935 Reputation points Independent Advisor
    2025-11-25T13:55:42.8666667+00:00

    Hello,

    You are getting that error because the calculated column is trying to read a value from another table without telling DAX which single row to use. For Pivot use a measure instead and pull the margin from the related table with RELATED.

    In Power Pivot, in table Fact_Sales, create a new measure and paste this:

    Margin$ := SUMX(Fact_Sales, Fact_Sales[Units Sold] * Fact_Sales[UnitPrice] * RELATED(Dim_Suppliers[Negotiated Margin]))
    

    Add this measure to your Pivot. It multiplies Units Sold by UnitPrice by the negotiated margin that is reached through the relationships Fact_Sales > Dim_Products > Dim_Suppliers. If Dim_Suppliers has more than one row per product category, make it one row per category or change RELATED to an explicit aggregator such as MAX to force a single value.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.