cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Dellis81
Responsive Resident
Responsive Resident

Weighted Average

Hello - I am needing help with a weighted average calculate across multiple combination of categories.   This is a first attempt, utilizing PBI quickmeasures - unfortunately only allows one category

 

Moisture WtAvg per Field = 
VAR __CATEGORY_VALUES = VALUES('Table'[Field])
RETURN
	DIVIDE(
		SUMX(
			KEEPFILTERS(__CATEGORY_VALUES),
			CALCULATE([SumMoisture] * [WetBushels])
		),
		SUMX(KEEPFILTERS(__CATEGORY_VALUES), CALCULATE([WetBushels]))
	)

 

I am really needing a single? measure that can handle most any combination of categories.

 

The three most needed are identified in the attached file - as visuals.

 

The blue circled should be 14.0% and Red 20.87%

 

WtAvg.PNG

Hopefully this google link with example file will work for you!

https://drive.google.com/open?id=1H4-ELiGSIK-v3el6zlBNABFugJfModo0

 

As Always - thank you!

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

You need to iterate at the lowest level of granularity for it to work properly at all levels.

 

In this case, you can iterate at the table row level to keep things simple.

 

 

Avg Moisture =
DIVIDE (
    SUMX ( 'Table', [SumMoisture] * [WetBushels] ),
    SUMX ( 'Table', [WetBushels] )
)

 

Note that this gives 14% for both numbers circled. The value 20.87% makes no sense when all of the moisture measurements are below 16%.

View solution in original post

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

How did you calculate the 20.87%?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Sorry, I was working off a spreadsheet, and had a transposed number.   Appreciate your time - solution has been found.

AlexisOlson
Super User
Super User

You need to iterate at the lowest level of granularity for it to work properly at all levels.

 

In this case, you can iterate at the table row level to keep things simple.

 

 

Avg Moisture =
DIVIDE (
    SUMX ( 'Table', [SumMoisture] * [WetBushels] ),
    SUMX ( 'Table', [WetBushels] )
)

 

Note that this gives 14% for both numbers circled. The value 20.87% makes no sense when all of the moisture measurements are below 16%.

Dellis81
Responsive Resident
Responsive Resident

Thank you very much.   After all my google searches, your solution is so elegant.   Apologize on the 20% number, I was working off a spreadsheet, and had a wrong number typed in.

 

Thank you!

Helpful resources

Announcements
August 2022 update 768x460.jpg

Check it Out!

Click here to learn more about the August 2022 updates!

August 1 episode 9_no_dates 768x460.jpg

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Top Solution Authors
Top Kudoed Authors