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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Hopulence
New Member

Weighted Average by Customer and Product

Hi all, 

 

Sorry if this has been answered elsewhere, but looking for some hopefully easy help. I am new to Power BI having extensive knowledge in QlikSense. I know the logic around how this should be done (AGGR in QS) but am not finding the right/best way in DAX to handle.

 

Basically I would like to have the weighted average cost by customer and by product. A sample table and expected results are below. I'd like to pull this value in a whisker table with just one dot per customer and product - doing a straight average of Cost is misleading.

 

One small caveat - in the source data, there are different amount of rows per "cost per unit" per Customer as this is actually distribution customers, meaning Customer A might have 10 end-customers who buy through them at $1.00, 5 customers who buy through them at $0.80, etc. So we have to be careful about summing up Unit Cost and likely should use average/distinct instead.

 

I'm sure this is a mix of sumx, calculate, evaluate, etc but proving fruitless so far. Below is a table that I hope comes through ok.

 

Thank you for your help!

 

Product Customer Cost per Unit        Units     PurchasedTotal      Cost Weighted Average Cost 

AAdams $                   1.00 50 $         50.00 
AAdams $                   0.80 100 $         80.00 
AAdams $                   1.24 10 $         12.40 $                                       0.90
ASmith $                   1.25 50 $         62.50 $                                       1.25
ARussel $                   0.90 25 $         22.50 $                                       0.90
BAdams $                25.00 21 $       525.00 
BAdams $                30.00 10 $       300.00 $                                     26.61
BSmith $                25.00 100 $   2,500.00 
BSmith $                15.00 75 $   1,125.00 $                                     20.71
1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

lbendlin_0-1712436083578.png

 

This is a measure but could also be a calculated column

View solution in original post

1 REPLY 1
lbendlin
Super User
Super User

lbendlin_0-1712436083578.png

 

This is a measure but could also be a calculated column

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.