Stumped by Sum and Countifs Formula

NorthbyNorthwest

Board Regular
Joined
Oct 27, 2013
Messages
154
Office Version
  1. 365
Hi, everyone. I have a formula that provides me with a count from a large table based on two criteria: review type or status and audit month. The formula returns the correct answer. The formula is:

=SUM(COUNTIFS(tblDivision[Review Type or Status],{"Routine","Makeup","Double"},tblDivision[Audit Month],"January"))


I have a second formula like the one above with a third criteria. The formula returns an incorrect count. It's not remotely close. I do not understand why it doesn't work. The formula is:

=SUM(COUNTIFS(tblDivision[Review Type or Status],{"Routine","Makeup","Double"}, tblDivision[Audit Month],"January",tblDivision[Audit Group],{"Team 1","Team 2"}))

Can someone assist.
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Unfortunately it isn't as simple as that when you have multiple columns with multiple choices. :(
There may be shorter ways but here are a couple of formulas you could try.
Excel Formula:
=LET(rts,tblDivision[Review Type or Status],am,tblDivision[Audit Month],ag,tblDivision[Audit Group],IFNA(ROWS(FILTER(tblDivision,((rts="Routine")+(rts="Makeup")+(rts="Double"))*(am="January")*((ag="Team 1")+(ag="Team 2")),NA())),0))
Excel Formula:
=SUMPRODUCT(ISNUMBER(SEARCH("|"&tblDivision[Review Type or Status]&"|","|Routine|Makeup|Double|"))*(tblDivision[Audit Month]="January")*ISNUMBER(SEARCH("|"&tblDivision[Audit Group]&"|","|Team 1|Team 2|")))
 
Upvote 0
Solution
Further to Peter's comments, your formula as written is counting only three possibilities:

Review typeMonthGroup
1RoutineJanuaryTeam 1
2MakeupJanuaryTeam 2
3DoubleJanuary#N/A

Other formulae you could use:

VBA Code:
=SUM(BYROW(tblDivision[Review Type or Status]={"Routine","Make up","Double"},LAMBDA(r,SUM(--r)))*(tblDivision[Audit Month]="January")*BYROW(tblDivision[Audit Group]={"Team 1","Team 2"},LAMBDA(r,SUM(--r))))
or
=SUM(MMULT(--(tblDivision[Review Type or Status]={"Routine","Make up","Double"}),{1;1;1})*(tblDivision[Audit Month]="January")*MMULT(--(tblDivision[Audit Group]={"Team 1","Team 2"}),{1;1}))
 
Upvote 0
Unfortunately it isn't as simple as that when you have multiple columns with multiple choices. :(
There may be shorter ways but here are a couple of formulas you could try.
Excel Formula:
=LET(rts,tblDivision[Review Type or Status],am,tblDivision[Audit Month],ag,tblDivision[Audit Group],IFNA(ROWS(FILTER(tblDivision,((rts="Routine")+(rts="Makeup")+(rts="Double"))*(am="January")*((ag="Team 1")+(ag="Team 2")),NA())),0))
Excel Formula:
=SUMPRODUCT(ISNUMBER(SEARCH("|"&tblDivision[Review Type or Status]&"|","|Routine|Makeup|Double|"))*(tblDivision[Audit Month]="January")*ISNUMBER(SEARCH("|"&tblDivision[Audit Group]&"|","|Team 1|Team 2|")))
Hi, Peter. Thanks so much for introducing me to the LET function. The formula works perfectly.
 
Upvote 0
Further to Peter's comments, your formula as written is counting only three possibilities:

Review typeMonthGroup
1RoutineJanuaryTeam 1
2MakeupJanuaryTeam 2
3DoubleJanuary#N/A

Other formulae you could use:

VBA Code:
=SUM(BYROW(tblDivision[Review Type or Status]={"Routine","Make up","Double"},LAMBDA(r,SUM(--r)))*(tblDivision[Audit Month]="January")*BYROW(tblDivision[Audit Group]={"Team 1","Team 2"},LAMBDA(r,SUM(--r))))
or
=SUM(MMULT(--(tblDivision[Review Type or Status]={"Routine","Make up","Double"}),{1;1;1})*(tblDivision[Audit Month]="January")*MMULT(--(tblDivision[Audit Group]={"Team 1","Team 2"}),{1;1}))
Hi, Stephen. Thanks for the assist. As I wrote Peter, I'm pretty lost when it comes to the newer Excel functions, like LET and LAMDA. I don't want to think about how many hours I would've spent on this had you and Peter not come to my rescue.
 
Upvote 0

Forum statistics

Threads
1,215,069
Messages
6,122,959
Members
449,096
Latest member
Anshu121

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top