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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register 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
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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