Average of a list and a single value

Hi

I would kindly like help from good community members on a formula of average rate for a modified sample stock management app. 

I want to calculate the average of initial stock rate and that of the subsequent purchase rates. Only the following formula seems to be working in virtual column 'Average Rate' of the 'Products' Table.

AVERAGE(SELECT(Purchases[Purchase Rate], ([Product Barcode] = [_THISROW].[Product Barcode])))

This formula only gives average of subsequent purchase rates but does not include rate of initial stock.

I have tried the following expression also which is not giving the desired result:

SUM(SELECT(Purchases[Purchase Rate], ([Product Barcode] = [_THISROW].[Product Barcode]))) + ([Product Barcode].[Rate])/(COUNT(SELECT(Purchases[Purchase Rate], ([Product Barcode] = [_THISROW].[Product Barcode]))) +1 )

Can someone guide me the correct expression. 

Solved Solved
0 3 129
1 ACCEPTED SOLUTION

Thank you!! It's working 

View solution in original post

3 REPLIES 3

With your details it sounds like the calculation is happening in a wrong order. Try to wrap this with extra parentheses like..

(SUM(SELECT(Purchases[Purchase Rate], [Product Barcode] = [_THISROW].[Product Barcode])) + [Product Barcode].[Rate])

Thank you!! It's working 

Good to hear!

Top Labels in this Space