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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
ssc
New Member

Getting a Weighted Average For Selected Rows

I have a small data set, with a few values. I've simplified this as shown below:

DateEventOpponentSetPlayerAttemptsAcesErrorsServeRating TotalServe %
1/9/2022P1 17Energy 17155211280%
1/9/2022P1 17Energy 1714542013100%
1/9/2022P1 17Energy 172584024100%
1/9/2022P1 17Energy 1724531010100%
1/15/2022ClassicElevation 16 Ascent15201150%
1/15/2022ClassicElevation 16 Ascent1452003100%
1/15/2022ClassicElevation 16 Ascent2573019100%
1/15/2022ClassicElevation 16 Ascent245301467%
1/16/2022ClassicCSA 16 Navy1571017100%
1/16/2022ClassicCSA 16 Navy1452003100%
1/16/2022ClassicCSA 16 Navy25511780%
1/16/2022ClassicCSA 16 Navy2453004100%

 

My dataset as calulated averages already. For player 5, we can see the first date (1/9/2022), we have 80% and 100%. If I put these in a visual and get the average, I get 90%. However, the calculation is (attempts-errors)/attempts. If I calculate this from the raw columns, I'd get 92% because the 100% value is weighted with 8 attempts to the 5 for the single error.

I have been trying various SUMX () and AverageX() combinations, but I don't quite understand how I can get a measure or column that would give me 

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @ssc 

 

You can try the following methods.

Measure = 
VAR _table =
    SUMMARIZE ('Table','Table'[Date],'Table'[Player],
        "DIVIDE",
            DIVIDE ( SUM ( 'Table'[Attempts] ) - SUM ( 'Table'[Errors] ), SUM ( 'Table'[Attempts] ) ) )
RETURN
    SUMX ( _table, [DIVIDE] )

vzhangti_0-1681353747691.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-zhangti
Community Support
Community Support

Hi, @ssc 

 

You can try the following methods.

Measure = 
VAR _table =
    SUMMARIZE ('Table','Table'[Date],'Table'[Player],
        "DIVIDE",
            DIVIDE ( SUM ( 'Table'[Attempts] ) - SUM ( 'Table'[Errors] ), SUM ( 'Table'[Attempts] ) ) )
RETURN
    SUMX ( _table, [DIVIDE] )

vzhangti_0-1681353747691.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

That does appear to work. I'll test on a larger data set and repost, but can you explain how this works? I'm a little unsure of what is happening.

ssc
New Member

Lost part of my post. I am looking to understand how I can get a weighted average by date of 92% instead of 90% for a player.

Helpful resources

Announcements
FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.