doug_morris's avatar
doug_morris
Frequent Visitor
3 years ago
Status:
Needs Info

Please fix this defect in List.Average

List.Average is not computed correctly in this code.

 

[
    Source = #table({"Value"}, {{null}, {1}}) & #table({"Value"}, {{2}}),
    Avg = List.Average(Source[Value])
]

 

It computes to 1 whereas it should be 1.5. Such incorrect List.Average calculation seems to occur anytime you are working with a non-buffered table built by combining tables. If you do an average on a column from a table like the code above or in a Table.Group, the average calculation erroneously includes nulls in the value count for the denominator.  The error does not occur with List.NonNullCount, List.Median, or List.StandardDeviation. Also, if you buffer the table or buffer the list before averaging, the error does not occur.

3 Comments