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
joeguan
Regular Visitor

Weighted AVG Aggregation

Hi,

I got a problem when creating a calculated member in PowerBI.

 

Here is the sample data:

CategoryProductSoldTotal
111234444
1200
13366
2412
2555
261012
379992000
385050
391222

I want to have a Sold Rate as a calculated column.

If I create a calculated column in Excel pivot table, it would be:  IF(Sold = 0 , 0 , Sold/Total)

It works perfect as below:

  Values  
CategoryProductSum of SoldSum of TotalSum of Sold Rate
1112344442.8%
 2000.0%
 33664.5%
1 Total 12645102.8%
241250.0%
 555100.0%
 6101283.3%
2 Total 161984.2%
37999200050.0%
 85050100.0%
 9122254.5%
3 Total 1061207251.2%
Grand Total 1203660118.2%

 

However, when using the same calculation method in PowerBI Devide(Sheet1[Sold],Sheet1[Total],0), it doesn't show the same number especially after aggregation.

It show 49% in the grand total by averaging each Sold Rate item...  That's not reasonable...

 

If I write Devide(sum(Sheet1[Sold]),sum(Sheet1[Total],0)   , then every single row of Sold Rate shows 18.2%.

 

I just want it to be exactly the same as the data showed up in Excel pivot table. Any suggestions?

 

 

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

Hi @joeguan,

 

In your scenario, please create a measure instead of a calculated column like below to calculate rate:

 

Rate = DIVIDE(SUM(Sheet3[Sold]), SUM(Sheet3[Total]),0)

 

Then create a matrix visual, place Category and Product in Rows, Sold, Total and Rate in Values.

 

q6.PNG

 

Best Regards,
Qiuyun Yu

Community Support Team _ Qiuyun Yu
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-qiuyu-msft
Community Support
Community Support

Hi @joeguan,

 

In your scenario, please create a measure instead of a calculated column like below to calculate rate:

 

Rate = DIVIDE(SUM(Sheet3[Sold]), SUM(Sheet3[Total]),0)

 

Then create a matrix visual, place Category and Product in Rows, Sold, Total and Rate in Values.

 

q6.PNG

 

Best Regards,
Qiuyun Yu

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

Ahhh, I got you. Create a measure instead of a column. Thanks so much!

Hi @joeguan,

 

It seems that my solution works in your scenario. If that is a case, would you please mark a proper reply as an answer so that we can close the thread? Smiley Happy

 

Best Regards,
Qiuyun Yu

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

Hey Qiuyun, As I mentioned, if I use your formula, every single row shows 18.9%(the grand total number). I can't make a filter on category column though. Because it is always 18.9%...

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!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.