cancel
Showing results for
Did you mean:
Frequent Visitor

## Weighted Distribution calculation

Hello,

I have the following table:

 Client Products Sales 100042 product1 24 100070 product2 20 100070 product1 24 100075 product2 20 100075 product3 24 100075 product4 24 100081 product2 20 100081 product3 24

I need to calculate weighted distribution using DAX formula for each product, example of calculation for product1 is below:

 Product1 Value Description Total sales of clients where product1 was sold 68 Total sales of all clients 180 Weighted distribution 37.8% 68/180

The main issue with calculation of [Total sales of clients where product1 was sold]. How to reach it in DAX PBI?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Established Member

## Re: Weighted Distribution calculation

Hi @raimkulov,

Please see the attached PBIX file update with your requirement. I have created a calculated column to calculate your desired result.

If this helped you, please mark this post as an accepted solution and like to give KUDOS .

Regards,

Affan

7 REPLIES 7
Super Contributor

## Re: Weighted Distribution calculation

Hello @raimkulov

You just need to apply the filter within CALCULATE

CALCULATE( <your sum measure>, Products[Product] = 'Product1' )

Proud to be a Datanaut!

Established Member

## Re: Weighted Distribution calculation

Hi @raimkulov,

You can used the below dax measure.

```WeightedAvg = var _total=CALCULATE(SUM(Table1[Sales]),ALL(Table1))
var _prodsum=CALCULATE(SUM(Table1[Sales]))
Return
_prodsum/_total```

You can find the pbix file here.

If this helped you, please mark this post as an accepted solution and like to give KUDOS .

Regards,

Affan

Frequent Visitor

## Re: Weighted Distribution calculation

Hi @affan,

Unfortunately, this is not what I am asking for.

In your pbi-file for product1 weighted distribution is 26.67% but it should be 37.78%, numerator should be 68 not 48 (24+24+20).

I need to sum total sales of clients where product1 was sold. It means that I sum not only product1 but produt2 for client 100070.

Highlighted
Established Member

## Re: Weighted Distribution calculation

Hi @raimkulov,

Please see the attached PBIX file update with your requirement. I have created a calculated column to calculate your desired result.

If this helped you, please mark this post as an accepted solution and like to give KUDOS .

Regards,

Affan

Frequent Visitor

## Re: Weighted Distribution calculation

Hi @affan,

Thanks a lot!

This is exactly what I needed.

Occasional Visitor

## Re: Weighted Distribution calculation

Hi @affan !

Could you paste DAX as I cannot open Dropbox files?

Thank you!

Established Member

## Re: Weighted Distribution calculation

I have created a custom column

`CustSum = CALCULATE(SUM(Table1[Sales]),FILTER(ALL(Table1),Table1[Client]=EARLIER(Table1[Client])))`

Then I have created the following measure

```WeightedAvg = var _total=CALCULATE(SUM(Table1[Sales]),ALL(Table1))
var _prodsum=CALCULATE(SUM(Table1[CustSum]))

Return
_prodsum/_total```

Regards

Affan

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: 113 members 1,606 guests
Recent signins: