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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
viitama
Frequent Visitor

weighted average for groups

Hi, I have simple calculation, that I thought would work with filtering, but I can't get it to work. My data:

Table1Table1

I thought that my formula for result fieldwould work when slicing with groups but it doesn't.

Result = (Table1[Value] / sum(Table1[Value]) * Table1[X])

Correct results calculated with excel are -13.333 for group A and -35.5556 for group B. I assume that my sum functions doesn't work in filtering but how do I write this that weight part is only calculated for grouped part?

 
 
 
 
 
 
1 ACCEPTED SOLUTION
v-yulgu-msft
Employee
Employee

Hi @viitama,

 

Please try this measure:

Result =
SUMX (
    Table1,
    CALCULATE (
        MAX ( Table1[Value] )
            / CALCULATE ( SUM ( Table1[Value] ), ALLEXCEPT ( Table1, Table1[Group] ) )
            * MAX ( Table1[X] )
    )
)

1.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
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

1 REPLY 1
v-yulgu-msft
Employee
Employee

Hi @viitama,

 

Please try this measure:

Result =
SUMX (
    Table1,
    CALCULATE (
        MAX ( Table1[Value] )
            / CALCULATE ( SUM ( Table1[Value] ), ALLEXCEPT ( Table1, Table1[Group] ) )
            * MAX ( Table1[X] )
    )
)

1.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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