Countif with dates does not work - excel

I couldn't find a similar question that's why I asked a new one.
I have a worksheet with two columns - first column shows month and year in the following format "mon.year", for example "apr.2017" and the second one shows a number. The number must represent the count of some other dates filtered by specific criteria. I have those dates in another sheet - one column with name and one with a date.
What I want to do is count the number of dates for example from june 2017 from the second sheet and place the number in the second column in the first sheet.
Here is how the first sheet looks like:
And this is how the second sheet with data looks like:
The result I'm looking for is this:
So, I tried the following code but I can't figure out why it doesn't work.
Any suggestions how to improve the formula?
EDIT: So, both the comments below were helpful for me but as the formula had to be simplified at most (my colleagues work with the excel file, not me) I chose to calculate the month and year in two hidden columns, then use the countif formula on them.

You will need to bracket the dates:
=COUNTIFS('1'$B$2:$B$26,">=" & EOMONTH(A2,-1)+1,'1'$B$2:$B$26, "<" & EOMONTH(A2,0)+1)

For Excel, a date/time is just a formatted number, the number of days since a fixed epoch.
"="&MONTH(A2) is an expression which concatenates the string = with the result of the function MONTH(A2), which is 1. The result of the expression is =1, which is what COUNTIFS sees.
You're actually telling COUNTIFS to match the date/time whose serial number is 1 (December 31, 1999 at midnight). Similarly, the second criteria will match exactly on July 9, 1905 at midnight.
My suggestion for you is to compute the month and year of each date on separate columns, and use COUNTIFS on these columns.

Related

Count How Many License Registered in the specific month

How to formula using CountIf function in Excel to get the count of licenses registered in January given the Register date is complete date format. Below is the sample structure of Excel data. As shown in the table below, there are 3 licenses registered in the month of January.
You can add a new column for the month, which I'll call B, and put the following function in the first cell of that column, and then copy it down:
=Month(B1:B4)
Then where you want the count to appear (I used C5), use the following formula:
=CountIf(B1:B5, 1)
This displays the following results:
This correctly performs the count regardless of the date format for the cell, as long as it's a date. In other words, it works for mm/dd/yyyy, d/m/yyyy, dd/mm/yyyy, and yyyy/mm/dd equally as well, which removes the issue of trying to parse out the first two characters of a string.
I tried various methods but i had to unfortunately use helper column to extract month number from dates. I used left function to extract month number as Left(B2,2). Then i used countif function to count all cells have "01" countif(C2:C6,"01"). This is not the best solution but it worked.

How do I sum a total number of occurrences of a ID number with a specific month and year in Excel

I have a Excel Master sheet where I am looking to query other sheets within the workbook. What I am trying to do is see How many occurrences of an ID for a Project in a column occur within a month, e.g. how many times does the ID 1367 occur in November. My dates are in the format of e.g 13/11/18 and this cannot be changed as I am just creating a report against a workbook I do not own.
The relevant columns I need are formatted like so:
Project: Project ID: Date:
a 123 1/01/2018
a 123 2/01/2019
a 123 3/01/2018
a 123
This is my SUMIFS function:
=SUMIF(PPlanner!$D:$D,Dashboard!$B$6,PPlanner!X:X)
This works by itself. My problem is trying to get the ID total for a specific month.
It returns the number of occurrences the ID occurs against a project all together but not against the month specifically. I have tried adding syntax to specify
the month but I am getting errors such as "too many arguments".
I recently answered a question that was very similar :
Excel - Take Average of Monthly Data
I think this would answer your question as well, but you have to use COUNTIFS instead of AVERAGEIFS
As for presentation, I would make a separate list of the months you want to include, and put the formula next to it, instead of the formula next to the actual list of data (as in the other question). As for how to write/input the month, you can put it any way you want, as long as it is a valid date in Excel. With the cell formatting you then can show it as month and year only. This is just to say that a text input JANUARY 2018 does not work (in a normal cell, eg. a cell that you did not format as text, when you type that into the cell, Excel recognizes this as a date, and will actually put 1/1/2018).
Oh, and using a Pivot table would work as well, the other answer on the question referenced above also explains how to do that.
In some cases, how Excel handles dates is very convenient.
For you, the date format doesn't matter. It is simply a number counting days with 0 being December 31st, 1899.
13/11/18 the date is the integer 43417 in-cell value. Excel interprets this as a both date and time together. The whole numbers are the days while the decimals are the time of day as a fraction of the day. 43417.5 would be noon.
So you may use COUNTIFS to help here.
=COUNTIFS(PPlanner!$X:$X, 1367, PPlanner!$D:$D, ">"&43404, PPlanner!$D:$D, "<"&43435)
This is going to look at sheet PPlanner column X and count how many instances of 1367 occur after the last day of October and before the first day of December. There are other ways to accomplish this, but it allows you to count within any date range you want.

Guide me Regarding Compare the Value of Cell contain date and other cell contain Drop down list

Hy Every One, I need help in excel formula, I have two sheets, sheet1 for sale tracker, sheet two for goals tracker, I used Now() to enter date automatically, and its working fine, Next in goal sheet, I use =Sumif() to calcualte various category totals and refer them in cell. Its also working fine. But I want to track record according to month and category. Like I have 6 categories detail is as under,
Sales Tracker
In the First picture Column Date consist of formula "=IF(ISBLANK(B5),"-",TODAY())" and it display the name of month like "October"
While in second picture there is a drop down list of "Month" Column.
1- I want to use if statement like =if(Date=Month, Sum(Revenue Secure column Data), "-") But its not working the formula I wrote here is an example....
2- I want when I select any month from second sheet like January, February, It should calculate sum from picutre one data and only show the sum of january etc.
Please help me, this is eating my brain a huge,,,,,,:)
Thanks in advance....
In short my question is how can I use If statement to compare value of cell that contain formula and other that contain drop down list?
Or use the MONTH function to change your date to a number 1 to 12 corresponding to the month. Then have the combo return a number for the month chosen. It might be faster using integers than test
I Believe you have to compare the month and not the whole date.
You can do TEXT(NOW();"mmmm") to get the full month name of the current data (in the language of excel) and then compare it to your drop down.
If you replace the NOW() with any data it works as well.

Excel - Highlight holidays on timesheet based on list of holidays

I have a list (for the rest of the year) of our recognized holidays at work, I want to highlight the row (just like I have the days off) if the day is one of the holidays. I have the dates for the holidays in text format in row O.
Them being text I figured I could use the same formula I am using for off days
=OR(LEFT(TEXT(C$8,"ddd"),2)=LEFT($G$5,2),LEFT(TEXT(C$8,"ddd"),2)=LEFT($H$5,2))
I just cant figure it out :/
Working off your previous formula I would use something along the lines of the following:
=SUMPRODUCT((LEFT(TEXT(C$8,"mmm"),3)=LEFT($O$3:$O$12,3))*(DAY(C$8)=--RIGHT($O$3:$O$12,2)))
Basically the formula will return the value of 1 which is equivalent to true for excel math if the first three letters of the month match and the date's day number match. All other results should return 0. It is also imperative that you do not have duplicate holiday dates in your list or the formula will return a value greater than 1. But there are ways around that too, but that is a follow up question.

Month-to-date totals

I have an Excel workbook that has several different worksheets in it. The one worksheet that contains the main data has 100's of entries. This sheet also gets a new entry every day in the row column. The first column is the date column that is formatted as date and time.
I need a formula that checks the newest entry's date to see if its month matches the current month and then sums all entries for that month. I know that I am going to use a SUMIF but the hard part is the rest of the formula. I forgot to mention that I need the formula to divide by the number of current month entries used.
Assuming your dates are in A1:A26 and amounts to be summed are in in B1:B26 here is the formula to use.
=SUMIFS(B1:B26,A1:A26,">="&DATE(YEAR(TODAY()),MONTH(TODAY()),1),A1:A26,"<="&TODAY())
This returns the amounts that are in a date that is greater than or equal to the first day of the current month, AND less than or equal to TODAY.
There are a couple ways you could do this and I would suggest using sumproduct formula.
I'm assuming your data has dates in column A starting in row 2, and a value in column B.
In column C you could have a total in each line which is the sum of all rows above the current one that the month matches.
Formula in C2 would be below which can be carried down
=SUMPRODUCT(--(MONTH(A2)=MONTH($A$2:A2)),$B$2:B2)
Otherwise if you have a single cell and just want to get the latest total this formula would do it. This assumes the latest entry will also be the newest date (highest value)
=SUMPRODUCT(--(MONTH(MAX(A:A))=MONTH(A2:A1000)),B2:B1000)
In sumproduct the first part of the formula --(A=B) returns true or false values which equate to 1s and 0s. The second part is just your value columns.
The second formula does the same thing but it compares the month of the newest date to all others in the column.
Gordon
Since new entries are added daily I am assuming these are in date order ascending, so please try:
=SUMIF(A:A,">"&EOMONTH(TODAY(),-1),AD1:AD100)
or adjust the AD range to suit (could use AD:AD).

Resources