COUNTIFS Date contains this month - Google Sheets - google-sheets

Column A contains Datevalues.
Column B a String.
I would like to count all cells where A is this month and B contains a certain String.
Here is my approach: =COUNTIFS(B1:B; "Certain String"; MONTH(A1:A); MONTH(TODAY()))
Unfortunately this approach does not work. Any idea?

=COUNTIFS(B:B;"Certain String";A:A;">"&eomonth(Today();-1);A:A;"<="&eomonth(Today();0))
Does not count this month in other than this year.

=ARRAYFORMULA(COUNTIFS(B:B, "string", MONTH(A:A), "="&MONTH(TODAY())))

Related

Populating columns with days based on a selection

I am trying to build a sleep tracker in Google Sheets (link). The idea is to select a year and a month from a drop-down list in cells A1 and A2, which would then populate columns based on the number of days in that month. I have tried different formulas that I found on stack overflow and elsewhere, but could not get them to work.
In short:
I am looking for a formula that will populate the columns with days of that month and a name of the day in a row bellow.
Looking for a way to summarize the time of sleep at the end of the each day, based on a ticked checkbox.
I am not sure how the year and month selectors should be formatted (as plain number or a date).
Is there a way to automatically insert check-boxes to the days of the month?
This is the formula that I have tried to adjust:
=INDEX({TEXT(SEQUENCE(1; DAY(EOMONTH(A2&"/"&A1;0)); A2&"/"&A1; 1); {"d"; "ddd"}); {"Total"; ""}})
But it returns with "Error In ARRAY_LITERAL, an Array Literal was missing values for one or more rows."
Please note that ";" is used as an argument separator instead of "," (regional settings).
Thank you in advance!
I think that with a very small adaptation and date formatting you'll be able to easily do it. First with your selector in A2, you could set it as actual dates, but format them as mmmm:
Then, repeat the sequence in both rows starting in C2 and C3:
=SEQUENCE(1,DAY(EOMONTH(A2,0)),A2)
But formatting row 3 as ddd:
PS: yes, you can do row 3 with TEXT and INDEX. Choose your preferred one:
=INDEX(TEXT(SEQUENCE(1,DAY(EOMONTH(A2,0)),A2),"dddd"))
UPDATE with TEXT VALUES
Return to your previous A2 dropdown and try this, using MATCH to find the number of the month, and DATE to locate the correct beginning of the month in that year:
For row 2:
=SEQUENCE(1,DAY(EOMONTH(DATE(A1,MATCH(A2,{"January","February","March","April","May","June","July","September","October","November","December"},0),1),0)),
DATE(A1,MATCH(A2,{"January","February","March","April","May","June","July","September","October","November","December"},0),1))
For row 3:
=INDEX(TEXT(SEQUENCE(1,DAY(EOMONTH(DATE(A1,MATCH(A2,{"January","February","March","April","May","June","July","September","October","November","December"},0),1),0)),
DATE(A1,MATCH(A2,{"January","February","March","April","May","June","July","September","October","November","December"},0),1)),"dddd")
)

Google Sheets / COUNTIF value is X and date is TODAY

I have a long list of dates in column C with a long list of names in column D.
I need to count how many times a certain name is mentioned but only if the date next to it is today.
So if today's date is 16/11/2022, and I want to find the name "Peter", this formula should return "2".
Column C
Column D
16/11/2022
Peter
16/11/2022
Peter
17/11/2022
Peter
Any ideas? Thanks!
use:
=COUNTIFS(C:C; TODAY(); D:D; "Peter")
update:
=INDEX(COUNTIFS(INT(C:C), TODAY(), D:D, "Peter"))

Sum range by month in Google Sheets with date conditional

I have a sheet with these columns:
A (Date): Range of dates for the year
B (Amount): An amount for an expense
D (Month): Name of each month in the year (e.g. June, July, etc)
I've tried this as suggested to work in other posts:
=SUMPRODUCT(B:B, ISDATE(A:A)*MONTH(A:A)=MONTH(D3&1))
I get the error Function MONTH parameter 1 expects number values. But 'Date' is a text and cannot be coerced to a number. with this.
If I remove the header, I just get a 0 for the sum for each month, which is incorrect.
How do I get this to work for each month the way my sheet is setup?
What the sheet currently looks like:
https://docs.google.com/spreadsheets/d/1_8DQTa9aXGjvd7twL6RZMcFyqxa4Sg7eVTcD2wDXH2A/edit?usp=sharing
Try this instead. Not sure where you got that other formula:
=SUMPRODUCT(B:B,TEXT(A:A,"mmmm")=D3)
use:
=ARRAYFORMULA(IFNA(VLOOKUP(MONTH(D3:D10&1),
QUERY(A2:B, "select month(A)+1,sum(B) group by month(A)"), 2, )))
Use this
=IF(D3="",,IFERROR(SUM(FILTER($B$2:$B,MONTH($A$2:$A&1)=MONTH(D3&1))),""))

How to sum values in a column based on day of the week in Google sheets

I have a Spreadsheet with duration values in one column, and date values in another.
I want to sum duration values based on a particular day of the week... eg, in the example screenshot, the first and last dates are Friday. So I want a formula that would add the duration values from the corresponding cells... a total of 17:00
I've tried a formula like this. But this doesn't work.
=SUMIF(D:D, CHOOSE(WEEKDAY(DATE(),2), "Fri") , A:A)
You could try:
=sumproduct(weekday(A:A)=6,D:D)
try:
=TEXT(ARRAYFORMULA(SUMIF(WEEKDAY(A:A, 11), 5, D:D)), "[h]:mm")
Not sure if there is an easy way because I'm noob at Google Sheets, but try with array formula:
=ArrayFormula(SUMIF(D1:D3;WEEKDAY(A1:A3;2);5))
Using it as array formula, I got this:
Hope this helps
One approach to do this is the following:
In column E put the weekday values. Use WEEKDAY() function which depending on your setting will make Friday any integer between 1-7. If using default Friday will be "6".
Use the SUMIF() function. Eg.=sumif(E:E,"=6",D:D)
Make sure the cell where your SUMIF() formula resides, also has a duration number format.

Count Number of Each Month in Column of dates in Google Spreadsheet

I have a Google sheet with a column of dates. I would like to get a total for each month, so that I can see how many of the dates are January, February, March, etc. This formula does not work (Dates is the name of range):
=COUNTIF(Dates,Month=1)
Any help is appreciated.
Following the logic of your proposition, the error is that MONTH() returns an integer, not an array. You can add ARRAYFORMULA() to do the job :
=COUNTIF( ARRAYFORMULA( MONTH( Dates ) ), "=2" )
I finally devised the correct search term for Google help
=sumproduct(month(Dates)=2)

Resources