Forum Discussion

heitorodriguess's avatar
heitorodriguess
Regular Visitor
5 years ago

Weighted average price over the time | Recursive Measure

Hi everyone,

 

I have a table that summarizes my data per product type, date, quantity purchased, average price of purchasing, quantity sold, average price of sales and quantity balance. I would like create a measure that in anyway self-reference itself to calculate the average price of quantity balance over the time.

 

I have the following sample data example in Excel:

G12= ((F12-B12)*G11+(B12*C12))/F12

Measure:= [(200-100)*25,27 + 100*25,07] / 200

 

I'm strugling to performa a measure like that so I would really appreciate your help 🙂

 

Row/ColABCDEFG
1 QTY PurAvg PurQTY SalAvg SalBalanceMeasure
2A30010,2130010,3200,00
301/01/202010010,2500,0010010,25
416/01/202020010,1900,0030010,21
528/01/2020010,15010,2530010,21
604/02/2020010,3510010,3020010,21
721/02/20200020010,4000,00
8B50025,2120025,2730025,16
901/01/202020025,3100,0020025,31
1016/01/202010025,200,0030025,27
1128/01/20200020025,2710025,27
1204/02/202010025,0700,0020025,17
1321/02/202010025,1500,0030025,16
14C60017,9520018,0340017,95
1501/01/202030017,9300,0030017,93
1616/01/20200010018,0120017,93
1728/01/20200010018,0510017,93
1821/02/202030017,9600,0040017,95
19D5005,9406,105005,93
2001/01/20201005,9800,001005,98
2116/01/20201005,900,002005,94
2228/01/20201005,8600,003005,91
2304/02/20201005,8900,004005,91
2421/02/20201006,0100,005005,93
25Total190014,3870014,051200 

2 Replies

  • What is the formula for G9?  Fx -Bx is the previous balance, so F12-B12 is the same as F11 ?

    • heitorodriguess's avatar
      heitorodriguess
      Regular Visitor

      Hello lbendlin 

      The general formula would be the following:

       

      [(Balance - QTY Pur) * Previous Measure Value for that Item + (QTY Pur * AvgPur)] / Balance

       

      For G9 as there is no previous measure value for Item B, would be only (QTY Pur * AvgPur)] / Balance:

      (200*25,31)/200=25,31

       

      Fx - Bx is equal the previous balance only in case there is no QTY Sal

       

      I hope now it´s more clear.

      Thanks in advance!