Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
rachaelnelson
Frequent Visitor

Calculating Average Price Per Ton

I have a table of data that list all product sales.  I have a calculated column that calculates the cost / ton.  When I put this column in a matrix, each line calculates correctly but when I roll up the data to a product category or aggregate of the whole, the data is the average of each line ($226.73) and not total cost / total ton ($232.85).

 

How do I get the correct calculation in my matrix and in a card visual?  I would like to add a slicer with some the additional fields to filter to a particular date range, product category, etc but cannot do so until I figure out how to get the correct aggregate calculations.

 

Here is sample data:

ProductCostTonsCost/TonCategory
A5002250DA
A4752237.5DA
A4821.89255.026455DA
B2001200BF
B2100.9233.3333333BF
B2031.1184.5454545BF
 20708.89226.7342072
   232.8458943

 

1 ACCEPTED SOLUTION

Thank you, Vvelarde.  Your measure gave me the same values I was receiving with my current calculated column but it got me thinking and I was able to solve using the following:

cost/ton = CALCULATE(SUM(Table1[COST])/SUM(Table1[Tons]))

View solution in original post

3 REPLIES 3
Vvelarde
Community Champion
Community Champion

@rachaelnelson

 

Hi, use this measure:

 

AVGCost-Tons = AVERAGEX(Table1,Table1[Cost/Ton])

 

Regards

 

Victor

Lima - Peru




Lima - Peru

Thank you, Vvelarde.  Your measure gave me the same values I was receiving with my current calculated column but it got me thinking and I was able to solve using the following:

cost/ton = CALCULATE(SUM(Table1[COST])/SUM(Table1[Tons]))

@rachaelnelson

 

Yeah, sorry i had a bad read of your problem.

 

I thought you need 226.83 instead of  232.85.

 

Regards

 

Victor

Lima - Peru




Lima - Peru

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.