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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors