Reply
MulberyPie
Advocate I
Advocate I
Partially syndicated - Outbound

Calculating average values based on filter

I want to calculate one total weighted average based on all entries in a table that responds to user selected filters on the table.

In these tables the quantity is the weight and hardiness is the base value. 

So for table 1 the weighted avg would be 4.1785

MulberyPie_0-1652903024512.pngMulberyPie_2-1652903818377.png

 

But for table 2 the overall average would be 3.625

MulberyPie_1-1652903055558.png MulberyPie_1-1652903783694.png

How could I show a weighted average for all fields in a filtered table?

 

 

1 ACCEPTED SOLUTION
johncolley
Solution Sage
Solution Sage

Syndicated - Outbound

Hi @MulberyPie ,

 

Assuming I have your logic right - I think the answer you are expecting is 4.107 when nothing is selected? If so the following should work.

Weighted Avg = 
Var Plantvalue = SUMX(Plants, Plants[Quantity]*Plants[Hardiness ])
Var Quantity = SUM(Plants[Quantity])
Var result = Plantvalue / Quantity
Return
result

 

View solution in original post

4 REPLIES 4
johncolley
Solution Sage
Solution Sage

Syndicated - Outbound

Hi @MulberyPie ,

 

Assuming I have your logic right - I think the answer you are expecting is 4.107 when nothing is selected? If so the following should work.

Weighted Avg = 
Var Plantvalue = SUMX(Plants, Plants[Quantity]*Plants[Hardiness ])
Var Quantity = SUM(Plants[Quantity])
Var result = Plantvalue / Quantity
Return
result

 

Syndicated - Outbound

Sorry, I'm not super familiar with PowerBI is that a DAX function? Where would I use that?

Syndicated - Outbound

I think I figured it out. I'm assuming that it would be put into a new measure 🙂

Syndicated - Outbound

Hi @MulberyPie, sorry should have stated in my original message! Yes it's a new measure.

 

Hope the measure helped, if it addressed your problem please mark it as a solution!

avatar user

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 FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 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)