Simplify this formula containing sum(countifs() function

gfdwer2

New Member
Joined
Jan 22, 2020
Messages
24
Office Version
  1. 2016
  2. 2010
Platform
  1. MacOS
I NEED THIS FORMULA TO BE SIMPLIFIED BECAUSE IT TAKES A LOT OF TIME FOR EXCEL TO COMPUTE IT

Simple background, I need to count all the cells containing "OT 1","OT 2","OT 3","OT 4","OT 5","OT 6" from 7 columns (PROC1-7) , but only for a specific date (represented by A5)

=SUM(COUNTIFS(DATE,A5,PROC1,{"OT 1","OT 2","OT 3","OT 4","OT 5","OT 6"}))+SUM(COUNTIFS(DATE,A5,PROC2,{"OT 1","OT 2","OT 3","OT 4","OT 5","OT 6"}))+SUM(COUNTIFS(DATE,A5,PROC3,{"OT 1","OT 2","OT 3","OT 4","OT 5","OT 6"}))+SUM(COUNTIFS(DATE,A5,PROC4,{"OT 1","OT 2","OT 3","OT 4","OT 5","OT 6"}))+SUM(COUNTIFS(DATE,A5,PROC5,{"OT 1","OT 2","OT 3","OT 4","OT 5","OT 6"}))+SUM(COUNTIFS(DATE,A5,PROC6,{"OT 1","OT 2","OT 3","OT 4","OT 5","OT 6"}))+SUM(COUNTIFS(DATE,A5,PROC7,{"OT 1","OT 2","OT 3","OT 4","OT 5","OT 6"}))

FROM THE FORMULA ABOVE:
1. DATE is a range selection which is Column A from different sheet (DATA)
2. Content of Cell A5 is the first criteria I am looking for in range DATE
3. PROC1 is a range selection which is Column H from different sheet (DATA)
PROC2 is a range selection which is Column K from different sheet (DATA)
PROC3 - PROC7 so on and so forth
4. "OT 1" - "OT 6" are the text I am looking for in range PROC1-PROC7

I have to separate EACH PROC (Column H, Column K, so on so forth) because excel does not allow me to use all the columns at once like H:Z

sample excel sheet can be found in this link: sample.1.xlsm
 
Cross posted Simplify this formula containing sum(countis() function

While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules). This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
 
Upvote 0

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
I know it looks weird!

The DATE range is a single column, but PROC columns cover 7 columns and I needed the DATE column to be replicated into a similar sized array. Multiplying one single sized array by another results in an array of the correct size. It then tests that new array against your date criteria.

Hope that makes sense.
 
Upvote 0
the DATE array is multiplied by this simple array {1,1,1,1,1,1,1} which produces a 7 column wide array that has the DATE values spread across the 7 column width. This is then matched against the date criteria to produce an array of True/False values. This in turn is matched to the PROC columns and their criteria (the + between each test is effectively an OR function) to only select valid elements to be counted.

HTH
 
Upvote 0
ideally try this, but replace D3:J23 with a single range that spans Proc1-Proc7. I assume that there are as many rows in DATE as there are in PROC?

=SUMPRODUCT(--((DATE)*{1,1,1,1,1,1,1}=A5),--((D3:J23="OT1")+(D3:J23="OT2")+(D3:J23="OT3")+(D3:J23="OT4")+(D3:J23="OT5")+(D3:J23="OT6")))

PS, as far a I know there is no reason why you can't have a single named range covering all 7 columns, even if they are the entire column. Though as said previously its not clever to reference an entire column because of the size of the calculation involved.

HTH
I TRIED YOUR SUGGESTION BY REPLACING D3:J23 WITH DATA!H3:Z100 BUT IT GIVES ME VALUE ERROR
 
Upvote 0
it will if DATE does not have the same number of rows. The arrays in the sumproduct must be the same size.
 
Upvote 0
I WAS ABLE TO
I NEED THIS FORMULA TO BE SIMPLIFIED BECAUSE IT TAKES A LOT OF TIME FOR EXCEL TO COMPUTE IT

Simple background, I need to count all the cells containing "OT 1","OT 2","OT 3","OT 4","OT 5","OT 6" from 7 columns (PROC1-7) , but only for a specific date (represented by A5)

=SUM(COUNTIFS(DATE,A5,PROC1,{"OT 1","OT 2","OT 3","OT 4","OT 5","OT 6"}))+SUM(COUNTIFS(DATE,A5,PROC2,{"OT 1","OT 2","OT 3","OT 4","OT 5","OT 6"}))+SUM(COUNTIFS(DATE,A5,PROC3,{"OT 1","OT 2","OT 3","OT 4","OT 5","OT 6"}))+SUM(COUNTIFS(DATE,A5,PROC4,{"OT 1","OT 2","OT 3","OT 4","OT 5","OT 6"}))+SUM(COUNTIFS(DATE,A5,PROC5,{"OT 1","OT 2","OT 3","OT 4","OT 5","OT 6"}))+SUM(COUNTIFS(DATE,A5,PROC6,{"OT 1","OT 2","OT 3","OT 4","OT 5","OT 6"}))+SUM(COUNTIFS(DATE,A5,PROC7,{"OT 1","OT 2","OT 3","OT 4","OT 5","OT 6"}))

FROM THE FORMULA ABOVE:
1. DATE is a range selection which is Column A from different sheet (DATA)
2. Content of Cell A5 is the first criteria I am looking for in range DATE
3. PROC1 is a range selection which is Column H from different sheet (DATA)
PROC2 is a range selection which is Column K from different sheet (DATA)
PROC3 - PROC7 so on and so forth
4. "OT 1" - "OT 6" are the text I am looking for in range PROC1-PROC7

I have to separate EACH PROC (Column H, Column K, so on so forth) because excel does not allow me to use all the columns at once like H:Z

sample excel sheet can be found in this link: sample.1.xlsm
I WAS ABLE TO SOLVE THIS PROBLEM BY LIMITING MY RANGES TO A MAXIMUM OF 5000
 
Upvote 0
You can simplify with a wildcard then:

=COUNTIFS(DATE,A5,PROC1,"OT *")+COUNTIFS(DATE,A5,PROC2,"OT *")+COUNTIFS(DATE,A5,PROC3,"OT *")+COUNTIFS(DATE,A5,PROC4,"OT *")+COUNTIFS(DATE,A5,PROC5,"OT *")+COUNTIFS(DATE,A5,PROC6,"OT *")+COUNTIFS(DATE,A5,PROC7,"OT *")
 
Upvote 0
You can simplify with a wildcard then:

=COUNTIFS(DATE,A5,PROC1,"OT *")+COUNTIFS(DATE,A5,PROC2,"OT *")+COUNTIFS(DATE,A5,PROC3,"OT *")+COUNTIFS(DATE,A5,PROC4,"OT *")+COUNTIFS(DATE,A5,PROC5,"OT *")+COUNTIFS(DATE,A5,PROC6,"OT *")+COUNTIFS(DATE,A5,PROC7,"OT *")
THAT MAKES SENSE, I'LL TRY TO USE THAT AND UPDATE YOU
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,304
Members
452,633
Latest member
DougMo

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