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
opittaluga
Frequent Visitor

weighted average of a data inside a measurment

Hello community, I hope somebody can help me with this calculation.

 

The result I’m expecting is to show the weighted average of the price variation.

I will show how can I do this on power pivot and how far I’m with power BI.

For this I will need:

1) The weighted average price by quarter.

2) The price variation between the vendor’s price and the average price by quarter.  

3) And finally calculate the weighted average of those variations.

The Table

 

0.PNG

 

Excel

  • I calculated the average price and the total weight purchased per vendor per quarter by using a pivot table. To calculate the weighted average price.2.png

     

  • Then I calculated the price’ variation with a simple formula ((vendor price - average price) /average price.)

    3.PNG

     

     

 

  • Finally, I calculate the weighted average price variation using sum product formula.

 4.PNG

6.PNG

 

 

Power BI

  • I calculated the average price using the following formula:

Weighted Average Price = sum(Tabla1[Total])/sum(Tabla1[Amount (lb)])5.PNG

  • Then I obtained the price variation between the vendor’s price and the average price by using two formulas:

 

7.PNG

 

-Total weighted average = CALCULATE (SUM ( Tabla1[Total]) / SUM ( Tabla1[Amount(lb)] ); ALL ( Tabla1[Vendor ] ))

 

-Variation = ([Weighted Average Price]-[-Total weighted average])/[-Total weighted average]

 

  • 7.PNG

     

    Here is where I got stack. I don’t know how to get the weighted average of those variations. At the beginning, I thought it was the total  of the table, but it is not. The total on the table is a very different number.

Any ideas to solve this enigma?

 

Best

1 ACCEPTED SOLUTION
v-sihou-msft
Employee
Employee

@opittaluga

 

In this scenario, since you already put a measure into matrix, we can't define aggregation on a measure. And it's not possible to custom aggregation on Grand/Sub Total level.

 

For your requirement, it can't be achieved currently. Please vote a similar idea.

 

Regards,

View solution in original post

1 REPLY 1
v-sihou-msft
Employee
Employee

@opittaluga

 

In this scenario, since you already put a measure into matrix, we can't define aggregation on a measure. And it's not possible to custom aggregation on Grand/Sub Total level.

 

For your requirement, it can't be achieved currently. Please vote a similar idea.

 

Regards,

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.