简体   繁体   中英

Excel: calculate average of column B for same values of column A where only all values of column B to corresponding same A value is present

I have two columns of values. Column A all have a series of numbers which function as identifiers, column B have values ranging from 1 to 5 and also blank values. I would like to calculate the average of column B for each group of identifiers in column A but only if all values in column B for the corresponding identifier in column A are present (column A is sorted). I've included an image: excel list

As the image shows value 2877040366 has all values in column B filled but the value above it 351856821 has not. Is it possible to have in column C the rows repeatedly show the average of all values in column B for 2877040366 but not for 351856821.

Use this in C1 and drag it down:

=IFERROR(AVERAGEIFS(B:B,A:A,A1,B:B,"<>"&""),0)

With the above formula if there is no identifier for a value (all are blank), it will return a 0. You can modify the above formula to further suit your needs.

EDIT:

Try the following to return a value ONLY if all the identifiers are there:

=IF(AVERAGEIFS(B:B,A:A,A1,B:B,"<>"&"")=SUMIF(A:A,A1,B:B)/COUNTIF(A:A,A1),AVERAGEIFS(B:B,A:A,A1,B:B,"<>"&""),"")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM