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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Sudharsanan
Helper III
Helper III

Weighted Avg calculation

Hi friends,

 

I need help in calculating weighted avg for the below data using DAX. can someone help me?

 

Logic: (Sum of CY sales)/((sum of PY sales)/(sum of PY qty))*sum of Cyqty)))-1 

 

CustprodCySaleCyQtyPYSalePY Qty
1A1,193155267
2B1,16537772
3C1,02845963
4A80251,38910
5B79469228
6C76741711
7A71784,30348
8B49211,3503
9C45281934
10A44552293
11B40851,18316
12C37632422
13A35521,4208
14B29532703
15C23515713
16A215101,02250
17B16321,31118
18C119559031
19A785413
20B633412
21C6111022
22A4111545
23B291512
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Sudharsanan , Assuming all are columns

 

Divide(Sum(Table[CY sales]), Sumx(Table, Divide([PY sales],[PY qty]) * Table[Cyqty]) ) -1

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

View solution in original post

8 REPLIES 8
Fowmy
Super User
Super User

@Sudharsanan 

Can you reconfirm your logic?, I tred it on a worksheet and got 36.63%

Fowmy_0-1661334561779.png

 



Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Hi @Fowmy 

Hope this helps..

 

Sudharsanan_0-1661335938548.png

avg Price = (pysale/pyqty)*cyqty.

 

i am able to get the anwer correct for individual line but as a overall i am not getting it.

@Sudharsanan 
The measure provided by @amitchandak  should work,

W AVG = 

DIVIDE(
    SUM(Table2[CySale]),
    SUMX(
        TABLE2,
        DIVIDE( Table2[PYSale] , Table2[PY Qty] ) * Table2[CyQty] 
    )
)-1
 

Fowmy_0-1661336973098.png

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Thank you @Fowmy it works.

 

can you also guide me in using the filter under Sum X please? i need to filter the year in  some cases

@Sudharsanan 

It depends where your year column is, if it is in the same table then

W AVG = 

DIVIDE(
    SUM(Table2[CySale]),
    SUMX(
        FILTER ( TABLE2 ,TABLE2[Year] = 2022 ) ,
        DIVIDE( Table2[PYSale] , Table2[PY Qty] ) * Table2[CyQty] 
    )
)-1
Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Hi @Fowmy 

 

i am able to get the correct result for individual product but the overall value is still not coming up correctly.

amitchandak
Super User
Super User

@Sudharsanan , Assuming all are columns

 

Divide(Sum(Table[CY sales]), Sumx(Table, Divide([PY sales],[PY qty]) * Table[Cyqty]) ) -1

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

Thank you @amitchandak 

 

Are you able to get the answer 10.45%?

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 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.