Home » excel » Excel – testing two conditions in a row throughout spreadsheet

Excel – testing two conditions in a row throughout spreadsheet

Posted by: admin May 14, 2020 Leave a comment


I have multiple columns with things I need to summarize, but here is a simplified version:

Sheet (#1)

Test Group    Scenario    Test Result      
one           a           pass
one           b           fail
one           c           fail
two           a           pass
two           b           fail
two           c           pass
three         a           pass

And I have another Sheet (#2)

Test Group    Passes    Fails  Total
one           #         #      #
two           #         #      #     
three         #         #      #

I’m expecting results that look like:

Test Group    Passes    Fails  Total
one           1         2      3
two           2         1      3
three         1         0      1

I have been trying to create a formula which counts passes and fails in Sheet 1 based on the name of the Test Group in Sheet 2.

I’m not sure whether to use Count and If or CountIf or Countifs

I’ve resorted to something like =COUNTIF(‘Sheet 1’!C2:C4,”pass”) but this does not account for the possibility that more tests can be added later, and then I’d have to update each row in the summary to use new numbers.

Is there some simple way to do this?
I’m hoping for something that looks at the pair of data (test group, test result) and summarizes it.

(I tried http://office.microsoft.com/en-us/excel-help/count-how-often-a-value-occurs-HP010342339.aspx but that doesn’t seem to work for me)

How to&Answers:

Make this into a pivot table and you can do it quite easily

Insert>Pivot Table> select your range> click OK

Make the column/row/value labels look like in my picture

enter image description here


You can certainly use COUNTIFS:


I used this in the structure below:

enter image description here

The total shouldn’t be too difficult 🙂