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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
lulcasl
Frequent Visitor

How to calculate weighted average between two measures?

My problem is pretty much what the title says.

 

I have two measures and I need the row context to keep the same, but the subtotal context to be a weighted average, I'm stuck on this for about 2 weeks now.

 

The expected result is this:

 

lulcasl_0-1644284367319.png

 

This is the result I'm getting

 

lulcasl_1-1644284405394.png

 

Can someone give me any insight on what I'm doing wrong? I can't see any way out of this atm.

 

The spreadsheet I used as example:
https://www.mediafire.com/file/mnx9ugvii065ath/Example.xlsx/file

 

The PBIX data for easier understanding of the problem:
https://www.mediafire.com/file/1e7494i840lr0j1/Example.pbix/file

 

 

Thanks in advance!

 

 

1 ACCEPTED SOLUTION

Hi @lulcasl ,

 

Please try the following formula, on my computer, it takes only about 2 seconds to calculate the result.

 

Measure = 
IF (
    HASONEVALUE ( d_Tipos[Tipo] ),
    [Produtividade Calculada SAP],
    SUMX (
        ALLSELECTED ( d_Tipos[Tipo] ),
        [Produtividade Calculada SAP] * [Volume Realizado]
    ) / [Volume Realizado]
)

vkkfmsft_0-1644562707536.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
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
amitchandak
Super User
Super User

@lulcasl , try a new measure like

Divide(sumx(Table,[ProdCal]*[Volume realizado]), Sum(Table[Volume realizado]) )

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hello @amitchandak 

 

It worked, but now the measure is pretty much unusable, it's taking around 3 - 5 minutes to load cards and matrixes with the said measure.

 

Anything I can do to avoid this?

Hi @lulcasl ,

 

Please try the following formula, on my computer, it takes only about 2 seconds to calculate the result.

 

Measure = 
IF (
    HASONEVALUE ( d_Tipos[Tipo] ),
    [Produtividade Calculada SAP],
    SUMX (
        ALLSELECTED ( d_Tipos[Tipo] ),
        [Produtividade Calculada SAP] * [Volume Realizado]
    ) / [Volume Realizado]
)

vkkfmsft_0-1644562707536.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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