Feb 28 2024 06:31 AM
Hi,
I'm looking for a formula that counts the number of dates in a list fall within a certain month. If at all possible without intermediate steps.
To be more specific, I'm wondering if there's a formula that can perform the count as in the yellow cells below (now I added these manually). So counting in a list of dates (column B below) how many in month/year A, month/year B, etc
Thanks a lot for the help!
Feb 28 2024 06:51 AM
Easiest way is to create PivotTable. If with formula, in column D do you have texts or dates formatted as mmm/yy ?
Feb 28 2024 07:01 AM
In column D it's dates formated as mmm/yy.
Would a pivot also work if there's multiple columns to count? I used a simplified example but in reality will be about 10 columns of dates (e.g. project 1 registration, Proj 2,...). Then I would like to have the count per month per project (ie a table with for example projects listed horizontally and then listing the applicable months in date format as rows below)
Feb 28 2024 07:20 AM
Nope, PivotTable won't work such way, at least directly. As variant that could be like
=SUMPRODUCT( --(MONTH(range)=MONTH(fromDateCell))
assuming in range are dates
Feb 28 2024 07:33 AM
You can make short work of this task by unpivoting the registration columns and then creating a pivot table.
Unpivot columns - Power Query | Microsoft Learn
The unpivoting will arrange your data vertically so it's easy to pivot:
Feb 28 2024 08:16 AM
Feb 28 2024 08:19 AM
Feb 28 2024 08:51 AM
Feb 29 2024 06:02 AM
Feb 29 2024 08:23 AM
SolutionIn general that could be
=SUMPRODUCT(
( IFERROR( N(MONTH($B$2:$D$7)), 0) = MONTH($F2) ) *
( IFERROR( N(YEAR($B$2:$D$7)), 0) = YEAR($F2) )*
ISODD( ROW($B$2:$D$7) )
)
by adding one more criteria. Details depends on content, do you mean odd row within the grid, or odd row counting from the start of the range.
Feb 29 2024 08:58 AM
I mean odd row within the grid. Like in example below, in the columns C and E the even rows show the window for the activity, while the odd rows represent the actual date. I would like to count the months like in the table on the right. For the registrations, your earlier formula worked. For the completions, I would need to exclude the even rows since the windows of completion don't have to be counted.
My apologies for these additional questions. But while "playing around" new ideas come up
Feb 29 2024 09:15 AM
When you need to do that column by column. Registration dates are in even rows, competition ones - in odd rows.
Applied to columns separately mentioned formula shall work.
Mar 01 2024 02:05 AM
Mar 01 2024 06:03 AM
Great to know, thank you for the feedback
Apr 02 2024 09:01 AM
Wondering if it's possible to add an additional criterion. Like in below example calculate how many registrations in a certain month but only for new students (so only for those indicated with "Yes" in column C). Or in other words, an automated count in the cells in yellow.
Feb 29 2024 08:23 AM
SolutionIn general that could be
=SUMPRODUCT(
( IFERROR( N(MONTH($B$2:$D$7)), 0) = MONTH($F2) ) *
( IFERROR( N(YEAR($B$2:$D$7)), 0) = YEAR($F2) )*
ISODD( ROW($B$2:$D$7) )
)
by adding one more criteria. Details depends on content, do you mean odd row within the grid, or odd row counting from the start of the range.