Forum Discussion

capko's avatar
capko
Helper II
2 years ago
Solved

Compute weighed average by month

Hello,

 

I'm trying to find the way to do the following problem on PBI (I'm still pretty new). Let's say that I have the following table:

 

IDQuantityPriceMonthYear
1507.512023
2202.532023
1107.012023
35030.022023
157.612023
1107.722023
31520.022023
2103.022023
215.022023

 

This table will represent the price of sold items (1, 2, 3) in differents months taking into account the quantities and unitary prices. I would like to compute the weighted average of each one of the items by month.

 

I created a table with disticnt elements but I don't know how to calculate this weighted average...

  • Hi, capko 

     

    You can try the following methods.

    Measure = Var _N1=MAX('Table'[Price])*MAX('Table'[Quantity])
    Var _N2=CALCULATE(SUM('Table'[Quantity]),ALLEXCEPT('Table','Table'[ID],'Table'[Year],'Table'[Month]))
    Return
    DIVIDE(_N1,_N2)

    Is this the result you expect?

     

    Best Regards,

    Community Support Team _Charlotte

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

2 Replies