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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Weighted distribution column

Hi,

 

I need to calculate Sum of Sales for all Clients where a specific product was sold. EX.:

 

I have a matrix table, with the products as Rows and I need the Total sales, Sum of Sales for all Clients where a specific product was sold, and Weighted Distribution % as Columns.

 

I have calculated the Total sales but now I need the other variable "Sum of Sales for all Clients where a specific product was sold" to be able to calculate the Weighted Coverage.

 

Data Model consist of 2 tables:

1. Sales data - with Date, Client Name, Brand Name, Quantity

2. Brand Name - with Brand Name, Naming Convention

 

Key field of the relationship is Brand Name.

As a filter I have the date and the brand name.

 

Thanks.

 

 

1 ACCEPTED SOLUTION

hi  @Anonymous 

Just adjust the formula as below:

 

All products QTY at Clients where P was sold 2 = 
var _allclients=VALUES('Sales Table'[Client ]) 
Return
CALCULATE(SUM('Sales Table'[Qty]),FILTER(ALLEXCEPT('Sales Table','Sales Table'[Date]),'Sales Table'[Client ] in _allclients))

 

 

 

Regards,

Lin

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

9 REPLIES 9
Anonymous
Not applicable

@amitchandak @harshnathani @v-lili6-msft 

Sales data table format:

DateClient Product Qty
8/21/2020C1P30.1
8/22/2020C2P10.3
8/23/2020C3P20.89
8/24/2020C4P30.94
8/25/2020C5P10.4
8/26/2020C6P20.1
8/27/2020C7P10.6
8/28/2020C8P30.7

 

Brand Name table format: 

 

ProductNaming Convention
P1Product 1
P2Product 2
P3Product 3

 

Below you can see the expected results:

 ClientsP QtyAll products QTY at All ClientsAll products QTY at Clients where P was soldWeighted Distribution
P128372.663.7755.8288%
P228932.3763.7755.0686%
P318201.2463.7746.2473%

 

I already have the columns "Clients, P Qty, All products QTY at All Clients." Now I just need the "All products QTY at Clients where P was sold " and once I have it, I can calculate the Weighted Distribution by dividing: "All products QTY at Clients where P was sold "/ "All products QTY at All Clients" = "Weighted Distribution"

Thanks in advance.

hi  @Anonymous 

Based your sample data, we could not get how to calculate [All products QTY at Clients where P was sold]

7.JPG

 

and i think if you just use this formula:

All products QTY at Clients where P was sold = CALCULATE(SUM(Sales[Qty]))
 
please share more sample data for this.
 
Regards,
Lin
Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

@v-lili6-msft Thanks for your reply.

Table 1:

Client Product Qty
C1P30.1
C2P10.3
C3P20.89
C4P30.94
C1P10.4
C2P20.1
C3P10.6
C4P3

0.7

 

 

 

Table 2:

ProductNaming Convention
P1Product 1
P2Product 2
P3Product 3

 

 

The outputs, based on datasets are:

 ClientsP QtyAll products QTY at All ClientsAll products QTY at Clients where P was soldWeighted Distribution
P131.34.032.3959%
P220.994.031.8947%
P321.744.032.1453%

 

Appreciate your help.

hi  @Anonymous 

Just create a meausre as below:

All products QTY at Clients where P was sold = 
var _allclients=VALUES('Table 1'[Client ]) return
CALCULATE(SUM('Table 1'[Qty]),FILTER(ALL('Table 1'), 'Table 1'[Client ] in _allclients))

 

All products QTY at All Clients = CALCULATE(SUM('Table 1'[Qty]),ALL('Table 2'))
Weighted Distribution = DIVIDE([All products QTY at Clients where P was sold],[All products QTY at All Clients])

Result:

3.JPG

 

and here is sample pbix file, please try it.

 

Regards,

Lin

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

@v-lili6-msft thanks for your suggestion. It seems to be close, but it doesn't work for my example. I have played around, trying to "adapt" the formula, but I'm missing something. I suppose it is related to the filters that I have (Date and Product)

 

I've attached xlsx and .pbix files here (https://gofile.io/d/qx4AlR). I have no option to attach the files to thread, sorry.

 

hi  @Anonymous 

Just adjust the formula as below:

 

All products QTY at Clients where P was sold 2 = 
var _allclients=VALUES('Sales Table'[Client ]) 
Return
CALCULATE(SUM('Sales Table'[Qty]),FILTER(ALLEXCEPT('Sales Table','Sales Table'[Date]),'Sales Table'[Client ] in _allclients))

 

 

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-lili6-msft
Community Support
Community Support

hi @Anonymous 

you may need to use ALLxxxx function to in your measure to get it.

https://www.sqlbi.com/articles/managing-all-functions-in-dax-all-allselected-allnoblankrow-allexcept/

 

if not your case, please share your sample pbix file and expected output, that will be a great help.

Please see this post regarding How to Get Your Question Answered Quickly:
https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

 

Regards,

Lin

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

@Anonymous ,Can you share sample data and sample output in table format?

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
harshnathani
Community Champion
Community Champion

Hi @Anonymous ,

 

Please share sample data and expected output in text format.

 

Regards,
Harsh Nathani
Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors