1

I have been trying to work out how to count the number of times a value appears across a range, but only once per column.

Using the example data below, the results I want to get to are shown in the end cells. Using the =COUNTIF(A3:G5,J3) counts every time a name appears, causing double-ups on some days.

example

How can I make it count each name once per column, but across multiple columns (there would be 1 column for each day of the year in the real data)

Thanks

0

3 Answers 3

3

in A7 enter:

=IF(COUNTIF(A3:A5,$J$3)>0,1,0)

and copy this across to G7. then in H7 enter:

=SUM(A7:G7)

enter image description here

Sign up to request clarification or add additional context in comments.

1 Comment

Awesome. This works perfectly and I would have never thought of doing it this way. Many thanks.
2

You also can count values using single array formula:

=SUM(--(MMULT(TRANSPOSE(--($A$2:$G$4=I2)),ROW($A$1:$A$3)^0)>0))

Array formula after editing is confirmed by pressing ctrl + shift + enter

enter image description here

2 Comments

WOW. That is awesome. It might be a silly question, but why is the ROW a shorter range than the lit of people? I ran a test and had the ROW as the the full list and it seemed to work, but just wanted to check.
@deaddingo This is because the MMULT function requires that the second range have as many rows as the first range columns. After TRANSPOSE range A2:G4 becomes 3 columns x 7 rows, respectively the second argument must have three rows.
0

So the final question is 'count how many columns the name appears in'?

In which case you need a hidden row at the top or bottom of the sheet that contains everything in that column. Say it's row 1:

a) The formula in A1 would be =CONCAT(A3:A5), B1 would be =CONCAT(B3:B5) and so on (where the range covers rows 3 to 5). CONCAT sticks text strings together.
b) the cell doing the counting would be =COUNTIF(A1:G1, "*J3*"). What that does is check which cells in A1:G1 contain J3 among other things.

And voila, problem solved.

1 Comment

@Garysstudent's answer works just as well - it's another way of summing up each column separately and then doing the overall count.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.