Excel/Google Sheets COUNTIFS formula to count rows, but with a substring in the Range.

rolamento

New Member
Joined
Apr 20, 2023
Messages
14
Office Version
  1. 2016
Platform
  1. Windows
Hello all. I'm having a problem doing a simple COUNTIFS formula. I have to automate a spreadsheet that counts rows if it has the corresponding city, but only if the date is the date from another cell. Lemme post the table bellow:

Book1
ABCDE
1DatestampLocationCurrentDateCityCount
221/07/2024 16:30London21/07/2024London0
321/07/2024 17:53ParisParis0
423/07/2024 19:53BarcelonaNew York0
5Mexico City0
6Barcelona0
Sheet1
Cell Formulas
RangeFormula
E2:E6E2=COUNTIFS(B:B,D2,A:A,"*" & $C$2 & "*")


The first 2 columns are the result of a Google Forms, to count the birth city of people attending a meeting. And I want to consolidate all people that attended said meeting in the last 2 columns, by city. Also, I want to only count given a certain day, so that I could change it on the go to see which people were present in any day of the results. I don't want to create another column with a substring or such, to avoid confusion.

So, basically, I would need, in this mock example, London and Paris to be at 1. If I change the date from "C2" to "23/07/2024", only Barcelona would count to 1. I thought about using something like "LEFT(A:A; 10)" to extract a substring from the Datestamp, so that it would match the date from C2, but it didn't work. Any help would be appreciated! Thanks in advance.
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Try:

Book1
ABCDE
1DatestampLocationCurrentDateCityCount
27/21/24 16:30London7/21/2024London1
37/21/24 17:53ParisParis1
47/23/24 19:53BarcelonaNew York0
5Mexico City0
6Barcelona0
Sheet9
Cell Formulas
RangeFormula
E2:E6E2=COUNTIFS($A$2:$A$10,">="&$C$2,$A$2:$A$10,"<"&$C$2+1,$B$2:$B$10,D2)
 
Upvote 1
How about
Excel Formula:
=SUMPRODUCT((INT($A$2:$A$100)=$C$2)*($B$2:$B$100=D2))
 
Upvote 1
Solution
How about
Excel Formula:
=SUMPRODUCT((INT($A$2:$A$100)=$C$2)*($B$2:$B$100=D2))
That works on Excel, given the dates are "Date" data types, but I would need it to work on Google Sheets. I tried to make it work there, but all the dates are in the string format, and when I try to apply that formula it doesn't work, saying that the INT() function doesn't accept strings :c
 
Upvote 0
How about
Excel Formula:
=SUMPRODUCT((INT($A$2:$A$100)=$C$2)*($B$2:$B$100=D2))
Nevermind, I figured it out >:D Thanks a lot! Just one more thing: Is there a way to make the search case insensitive? Like if a city is spelled "london" instead of "London".
 
Upvote 0
Try:

Book1
ABCDE
1DatestampLocationCurrentDateCityCount
27/21/24 16:30London7/21/2024London1
37/21/24 17:53ParisParis1
47/23/24 19:53BarcelonaNew York0
5Mexico City0
6Barcelona0
Sheet9
Cell Formulas
RangeFormula
E2:E6E2=COUNTIFS($A$2:$A$10,">="&$C$2,$A$2:$A$10,"<"&$C$2+1,$B$2:$B$10,D2)
Yo this one also worked! Thanks a lot! I just have to figure out how to make the City name to be case insensitive >.<
 
Upvote 0
Yo this one also worked! Thanks a lot! I just have to figure out how to make the City name to be case insensitive >.<
Glad we could help. In Excel, COUNTIFS is case insensitive. I can't comment on Google Sheets.
 
Upvote 1
Both countifs & sumproduct are case insensitive in Excel & Sheets.
 
Upvote 1
Both countifs & sumproduct are case insensitive in Excel & Sheets.
Right, thanks! I managed to make it work with all your help, but I would like a suggestion. If, instead of a single date to compare, I passed a string with two dates. How could I make it work to get all matching rows between that range, for example "22/07/2024 - 25/07/2024". How to get all matching rows between day 22 and 25?
 
Upvote 0
As that is a totally different question, it needs a new thread.
Thanks
 
Upvote 1

Forum statistics

Threads
1,224,811
Messages
6,181,080
Members
453,021
Latest member
Justyna P

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