I am having difficulty calculating descriptive statistics based on multiple conditions in Excel.
Here's a subset of the dataset:
A B
1 2
1 3
3 1
1
The blanks indicate missing data - I cannot rename the blanks (e.g., -999 or NaN)
Let's say I want to calculate the average. I know that the true average for values which have an entry in both columns A and B is 1.67 (based on filtering the data to rows which have entries in both columns).
I have tried a series of functions to account for this condition (e.g., calculate the average of column A for values with an entry in both columns A and B) and the only function that works is AVERAGEIFS. However, I cannot rely on this because I want to use the code for any function, e.g., STDEV, for which an FUNCTIONIFS function does not (yet) exist.
Here's what I've tried, with no luck:
Here's the code for ease of copying+pasting:
=AVERAGEIFS(A:A,A:A, ">=0",B:B,">=0")
=AVERAGE(IF(A:A >=0,IF(B:B >=0,A:A)))
=AVERAGE(IF(AND(A:A >=0,B:B >=0),A:A))
=IF(A:A >=0,IF(B:B >= 0,AVERAGE(A:A)))
=IF(AND(A:A>=0,B:B>=0),AVERAGE(A:A))
=AVERAGE(IF((A:A>=0)*(B:B),A:A))
To recap, there are three conditions that are necessary:
- I need to reference the whole column (e.g., A:A) rather than index a subset of it (e.g., A1:A50).
- I need to include missing values as blanks
-
I cannot rely on AVERAGEIFS because I am looking to generalise the code to any function (e.g., STDEV)
Any guidance would be greatly appreciated.

Aucun commentaire:
Enregistrer un commentaire