0

I'm trying to create an Excel function that counts instances that meet 3 criteria. For example data in sample data, I want to:

1)For each type of 'Structure' count number of rows in which 2)'Horizontal' is greater than zero, OR 3)'Vertical' is greater than zero

Expected result for example data in column D.

An array formula of the type

=SUM(IF(($B$2:$B$7>0)+($C$2:$C$7>0),1,0))

counts in accordance with criteria 2) and 3) but does not group by 'Structure'.

Any thoughts?

Much appreciated.

2 Answers2

2

Edit following comment by Scott Cranger

If F2 contains the Structure type, then:

G2: =SUMPRODUCT(--((Structure_Type=F2)*((Horizontal>0)+(Vertical>0))>0))

where Structure_Type, Horizontal, and Vertical are the ranges containing those elements. This formula is normally entered.

Ron Rosenfeld
  • 53,870
  • 7
  • 28
  • 60
1

Try this Array formula:

=SUM(IF(($A$2:$A$7= A2)*(($B$2:$B$7>0)+($C$2:$C$7>0)),1,0))

Remember to use Ctrl-Shift-Enter.

The * is used for And and the + for Or. So this will pick up only those that have Structure in column A and has a greater than 0 in one or both of column B or column C

Scott Craner
  • 148,073
  • 10
  • 49
  • 81