cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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

Accepted Solutions
Highlighted
Microsoft
Microsoft

Re: weighted average for groups

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
Highlighted
Microsoft
Microsoft

Re: weighted average for groups

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

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

July 2020 Community Highlights

July 2020 Community Highlights

Learn about the exciting things that happened in July.

Upcoming Events

Upcoming Events

Wondering what events you could join or have an event to promote yourself? Check out our Upcoming Events.

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

We are thrilled to announce we will begin running a monthly webinar series named Power BI Dev Camp.

Top Solution Authors
Top Kudoed Authors