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

Table1

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
Super Contributor

## Re: weighted average for groups

Hi @viitama,

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

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.
Super Contributor

## Re: weighted average for groups

Hi @viitama,

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

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.

Announcements

#### Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

#### Community News & Announcements

Get your latest community news and announcements.

#### Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

#### Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Top Kudoed Authors
Users Online
Currently online: 140 members 1,534 guests
Recent signins: