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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
yaman123
Post Patron
Post Patron

Calculate Weighted Average

Hi, 

 

I am having difficulty in trying to calculate the weighted average from the dataset I have. 

 

I have unpivoted the data in query editor due to the nature of the data in the source. 

 

I want to work out the total weighted average per column e.g total weighted average for sp £/t, cos £/t and margin £/t. The Total row should show the weighted average

 

Expected: 

 TonnesSP £/tCOS £/t Margin £/t Margin £k
Downgrade5020003000-800-50
Mouldy00000
Traded2040005000-1000-30
Total7025713571-857-80

 

To calculate this for e.g sp £/t, i need to multiply tonnes by the sp £/t value so - ((52 * 2800) + (0*0) + (33*3030))/85

 

Below is the source table - 

Week NoW/CAttributeValue
4720/11/2023Downgrade Tonnes50
4720/11/2023Downgrade SP £/t2000
4720/11/2023Downgrade COS £/t3000
4720/11/2023Doiwngrade Margin £/t-800
4720/11/2023Downgrade Margin £k-50
4720/11/2023Mouldy Tonnes0
4720/11/2023Mouldy SP £/t 0
4720/11/2023Mouldy COS £/t 0
4720/11/2023Mouldy Margin £/t 0
4720/11/2023Mouldy Margin £k0
4720/11/2023Traded Tonnes20
4720/11/2023Traded SP £/t 4000
4720/11/2023Traded COS £/t 5000
4720/11/2023Traded Margin £/t-1000
4720/11/2023Traded Margin £k-30

 

 

Any help is appreciated! 

 

Thanks

 

1 REPLY 1
lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information or anything not related to the issue or question.

If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.