- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

# Weighted Distribution calculation

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

12-25-2018 01:41 AM

Hello,

Could you please help me to calculate weighted distribution using DAX?

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?

Thanks in advance.

Solved! Go to Solution.

Accepted Solutions

## Re: Weighted Distribution calculation

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

12-26-2018 02:02 AM

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

All Replies

## Re: Weighted Distribution calculation

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

12-25-2018 03:00 AM

Hello @raimkulov

You just need to apply the filter within CALCULATE

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

Did I answer your question? Mark my post as a solution!

**Proud to be a Datanaut!**

## Re: Weighted Distribution calculation

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

12-25-2018 05:21 AM

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

## Re: Weighted Distribution calculation

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

12-25-2018 08:12 PM

Hi @affan,

Thanks for the reply!

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.

## Re: Weighted Distribution calculation

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

12-26-2018 02:02 AM

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

## Re: Weighted Distribution calculation

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

12-26-2018 02:10 AM