Countifs multiple criteria including an array

CodenameAter

New Member
Joined
Jul 23, 2014
Messages
30
Would someone explain how to create a formula where I ask whether a particular value is equal to multiple criteria, including anything matching the criteria in any column of an array?

For example, in the made-up data below, I know how to write a COUNTIFS formula to ask if any data in ID1 and ID2 are equal to any other row except the current row and if the data also falls within a particular time window. However, if I want to also ask whether there is a "1" in SB-2, SB-3 or SB-4, the only way I know to do this is by adding criteria for each row. However, this is just an example and the actual data has many SB columns. I was wondering if I could ask if the array starting with SB-2 has the value 1 in any row of that array?

Let me know if this is making sense. Thank you,

ID1ID2DATE&TIMESB-2SB-3SB-4
AC2021-05-13 11:52:001
B2021-05-13 11:52:01
AC2021-05-13 11:52:02
DE2021-05-13 11:53:001
ED2021-05-13 11:53:141
DE2021-05-13 11:53:281
ED2021-05-13 11:53:421
ED2021-05-13 11:53:561
DE2021-05-13 11:54:101
ED2021-05-13 11:54:241
DE2021-05-13 11:54:381
BC2021-05-13 11:54:411
BC2021-05-13 11:54:421
AF2021-05-13 11:54:451
FA2021-05-13 11:54:49
DE2021-05-13 11:54:561
CB2021-05-13 11:54:57
DE2021-05-13 11:55:081
ED2021-05-13 11:55:091
DE2021-05-13 11:55:101
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Hi CodenameAter,

Is this the type of thing you were looking for?

CodenameAter.xlsx
ABCDEFGHIJK
1ID1ID2DATE&TIMESB-2SB-3SB-4Date&TimeResult
2AC5/13/2021 11:521Start13-May-2021 11:54:003
3B5/13/2021 11:52End13-May-2021 11:54:50
4AC5/13/2021 11:52
5AA5/13/2021 11:531
6ED5/13/2021 11:531
7DE5/13/2021 11:531
8ED5/13/2021 11:531
9ED5/13/2021 11:531
10DE5/13/2021 11:541
11DD5/13/2021 11:541
12BC5/13/2021 11:541
13BB5/13/2021 11:541
14AA5/13/2021 11:541
15AA5/13/2021 11:541
16DD5/13/2021 11:541
17CB5/13/2021 11:54
18DE5/13/2021 11:551
19DD5/13/2021 11:55111
20DE5/13/2021 11:551
21
22
Sheet1
Cell Formulas
RangeFormula
K2K2=SUMPRODUCT(--($A$2:$A$21=$B$2:$B$21)*($C$2:$C$21>=$I$2)*($C$2:$C$21<=$I$3)*($D$2:$D$21=1))
 
Upvote 0
Or maybe something like this:

Book1
ABCDEFGHIJKL
1ID1ID2DATE&TIMESB-2SB-3SB-4Date & TimeID1Result
2AC5/13/2021 11:521Start5/13/2021 11:00A2
3B5/13/2021 11:52End5/13/2021 12:00B2
4AC5/13/2021 11:52C0
5DE5/13/2021 11:531D7
6ED5/13/2021 11:531E5
7DE5/13/2021 11:531F0
8ED5/13/2021 11:531
9ED5/13/2021 11:531
10DE5/13/2021 11:541
11ED5/13/2021 11:541
12DE5/13/2021 11:541
13BC5/13/2021 11:541
14BC5/13/2021 11:541
15AF5/13/2021 11:541
16FA5/13/2021 11:54
17DE5/13/2021 11:541
18CB5/13/2021 11:54
19DE5/13/2021 11:551
20ED5/13/2021 11:551
21DE5/13/2021 11:551
Sheet1
Cell Formulas
RangeFormula
L2:L7L2=SUMPRODUCT(($A$2:$A$21=K2)*($C$2:$C$21>=$I$2)*($C$2:$C$21<=$I$3)*SIGN(MMULT(--($D$2:$F$21=1),TRANSPOSE(COLUMN($D$2:$F$2)^0))))


I didn't quite grasp

if any data in ID1 and ID2 are equal to any other row except the current row

so I left out ID2. But see if this is the right idea for looking at multiple columns.
 
Upvote 0
so I left out ID2. But see if this is the right idea for looking at multiple columns.

Thank you. Yes, I think this is the right idea. This is just sample data, so really I just need to understand the formula you use to calculate if multiple criteria are met on a particular row (i.e. ID1, ID2 and Date&Time in a row all meet the right criteria) then return a value if any column in an array on the same row also equals a particular value.

For example, rows 5 and 7 meet the criteria, so each of those rows should return a value that would populate in column G.

Let me read into the SIGN and MMULT functions because I am not familiar with them and get back to you. Stay tuned.
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,857
Members
449,051
Latest member
excelquestion515

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