Home » excel » excel – Calculating the average of value in group of cells

# excel – Calculating the average of value in group of cells

Posted by: admin May 14, 2020 Leave a comment

Questions:

I have an Excel sheet in this format. You can see that there are groups of dates, and there is a column `Present` with boolean values. I want to find the percentage of `Yes` in the `Present` field. If this was SQL, I would have done easily. I have a few questions in Excel.

1. Is this feasible?
2. What kind of formula should I use?
3. Should I use macros for these or just formulae would do?
4. Will I be able to fill the column automatically, without I merging cells each and every time manually?

I had played around with `COUNTIF` and `SUMIF`, but didn’t work for me. Please help. Thanks in advance.

How to&Answers:

You will need to use one `COUNTIF` and one `COUNTIFS`

In the first cell containing the percentage for instance, you could use:

``````=COUNTIFS(A:A,A2,B:B,"YES")/COUNTIF(A:A,A2)
``````

Assuming that `1-May-13` is in A2 and `Yes` is in B2.

`COUNTIFS` uses multiple criteria. Here, it counts only if the date in A1 is `1-May-13` and the value in B2 is `Yes`.

The `COUNTIF` just counts the number of times the date appears.

You can then format the column as a percentage.

It will be difficult I think with the merging and unmerging cells though.