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! Learn more

Reply
Anonymous
Not applicable

Weighted Average Price calculation - with multiple filters

Hi,

 

I have got below tables:

 

ClientProductSalesQTYAUPMonth Year
AABC$10050$2Aug 2022
BABC$24060$4Aug 2022
AABC$5005$10July 2022
BABC$30010$3July 2022

*AUP is Average Unit Price: Sales/QTY

 

So what I am trying to get is a Weighted Average of AUP within a certain Month Year for a given Product:

 

In Aug, the Weighted Average price for product ABC = (100/340) *2 + (240/340)*4

In July, the Weighted Average price for product ABC = (500/800) * 10 + (300/800)*3

 

Not too sure how to get this through DAX Measure?

 

 

Thanks!

 

 

1 ACCEPTED SOLUTION
v-jianboli-msft
Community Support
Community Support

Hi @Anonymous ,

 

Approve @ddpl . Here is another measure, please try:

Measure = DIVIDE(SUMX('Table',[Sales]*[AUP]),SUMX('Table',[Sales]))

Output:

vjianbolimsft_0-1660902559097.png

If you want to apply all the columns in the table visual, please try:

Measure 2 = 
var _a = FILTER(ALL('Table'),[Month Year]=MAX('Table'[Month Year]))
return DIVIDE(SUMX(_a,[Sales]*[AUP]),SUMX(_a,[Sales]))

Output:

vjianbolimsft_1-1660902884478.png

 

Best Regards,

Jianbo Li

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

4 REPLIES 4
v-jianboli-msft
Community Support
Community Support

Hi @Anonymous ,

 

Approve @ddpl . Here is another measure, please try:

Measure = DIVIDE(SUMX('Table',[Sales]*[AUP]),SUMX('Table',[Sales]))

Output:

vjianbolimsft_0-1660902559097.png

If you want to apply all the columns in the table visual, please try:

Measure 2 = 
var _a = FILTER(ALL('Table'),[Month Year]=MAX('Table'[Month Year]))
return DIVIDE(SUMX(_a,[Sales]*[AUP]),SUMX(_a,[Sales]))

Output:

vjianbolimsft_1-1660902884478.png

 

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

ddpl
Solution Sage
Solution Sage

@Anonymous First create calculated column "Weighted Average" as per below

 

Weighted Average = 
var _A = CALCULATE(SUM('Table (2)'[Sales]),FILTER('Table (2)','Table (2)'[Month Year] = EARLIER('Table (2)'[Month Year])))
         var _B =DIVIDE('Table (2)'[Sales],_A)*'Table (2)'[AUP]
         return
             _B
then create visual table as per below
 
ddpl_0-1660023981966.png

 

Please accept as a solution if its worked.

Anonymous
Not applicable

@ddpl  Thanks for your reply.  Can I ask why do you use "EARLIER" function here?

@Anonymous Earlier fuction we have used for grouping of the MontYear value so that we will get the total for A and B ie A = 340 and B =800 

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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