Reply
yaman123
Post Patron
Post Patron
Partially syndicated - Outbound

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

Syndicated - Outbound

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...

avatar user

Helpful resources

Announcements
March PBI video - carousel

Power BI Monthly Update - March 2025

Check out the March 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors (Last Month)
Top Kudoed Authors (Last Month)