+ Reply to Thread
Results 1 to 4 of 4

How to count dates/months and put it in a chart?

  1. #1
    Registered User
    Join Date
    09-28-2022
    Location
    switzerland
    MS-Off Ver
    MS 365 excel
    Posts
    2

    Question How to count dates/months and put it in a chart?

    I'd like to make a chart that updates whenever I put a date in it, it add's up.

    For exemple, i've got these dates:

    05/09/2021
    10/12/2021
    02/05/2022
    05/05/2022
    10/05/2022
    23/05/2022
    10/07/2022
    13/07/2022
    22/07/2022
    23/07/2022

    01/09/2022
    18/09/2022
    28/09/2022

    and i'd like to be able to put them in a chart so that i know how many "unit" are in may (so here it'd be 5) or september (here 4) and so on...

    If the same is possible with weekdays, like how many of them are on a monday...

    can anyone help me on that?

    thank you in advance!

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,819

    Re: How to count dates/months and put it in a chart?

    Do you want to use a pivot table or COUNTIFS() functions? Assuming you only have the date and they are stored as serial numbers, are you allowed to add helper columns?

    For counting how many records correspond to each month, a pivot table can "group" dates by whatever time unit you want, including month. So, build your pivot table so it is counting by date, select the "date" field, and instruct Excel to group by month. https://support.microsoft.com/en-us/...c-c84a5a340725

    If you prefer to use a COUNTIFS() function, you can count by month by counting records between first and last of a month. =COUNTIFS(dates,dates,">="&DATE(2022,1,1),dates,"<"&DATE(2022,2,1)) will count the records in January. You can use formulas and cell references or other strategy for automating the criteria dates.

    For something like "day of the week," you can add a helper column to your source data that extracts "day of the week" from the date using the WEEKDAY() function (https://support.microsoft.com/en-us/...0-e404c190949a ), then use either a pivot table or COUNTIFS() to count by weekday.

    Options and choices, and I'm not sure we can make those choices for you, but, if you will help us understand you requirements and constraints and such, we should be able to help come up with a workable solution.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Registered User
    Join Date
    09-28-2022
    Location
    switzerland
    MS-Off Ver
    MS 365 excel
    Posts
    2

    Re: How to count dates/months and put it in a chart?

    I'd like to do it by using COUNTIF, i tried with what you gave me but couldn't make it work.

    Yes it is possible to add helper columns, such as that one:

    Type
    AL AUT
    AL AUT
    DH
    DH
    Fire
    AL AUT
    Inondation
    Fire

    DH
    Feu
    Divers

    so it would give me something like this:
    Attachment 798268

  4. #4
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,819

    Re: How to count dates/months and put it in a chart?

    Latest attachment failed to attach. Be sure you are following the instruction for adding attachments at the top of the page.

    If you can add columns to the source data, then add columns that will show the desired criteria you wish to count by. For calendar month, you might add a column that uses the MONTH() function to get calendar month for each date value (=MONTH(A2)). Use the WEEKDAY() function to get the day of the week for each date. And so on.

    From there it should be straightforward to use the COUNTIFS() function to get the desired counts. Your latest post suggests that there is more to the database than just dates, you also have some kind of Type in each record. To count all "DH" types during the month of Jan 2022:

    1) Choose a location for the summary table. (I will start in AA1 for illustration, and assume dates are in column A starting in A2 and types are in column B starting in B2).
    2) In AA1 enter "start date." In AB1, enter "end date." In AC1 enter, "Type." In AD1 enter "count" for headers so you can remember what each column is doing.
    3) In AA2, enter 1 Jan 2022, In AB2, enter 1 Feb 2022. In AC2 enter, "DH." In AD2 enter =COUNTIFS($A$2:$A$200,$A$2:$A$200,">="&AA2,$A$2:$A$200,"<"&AB2,$B$2:$B$200,AC2)

    To count for the first day of the week.

    4) In C1 enter, "Day of week." In C2, enter =WEEKDAY(A2) and copy/paste/fill down/
    5) In AE1 enter, "Day of week." In AF1 enter "count"
    6) In AE2 enter 1. In AF2 enter =COUNTIFS($C$2:$C$200,AE2)

    From there, you can add or remove criteria to get whatever combination of criteria you want. Just be clear that COUNTIFS() always use "and" logic when combining multiple criteria. If you are unfamiliar with the syntax of the COUNTIFS() function: https://support.microsoft.com/en-us/...c-aa8c2a866842

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Need to Count how many months two different dates are apart
    By ibuhary in forum Excel General
    Replies: 2
    Last Post: 09-30-2019, 10:18 AM
  2. Count how many dates are this month, 2 months and 3 months old
    By jimmisavage in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 06-21-2017, 09:21 AM
  3. [SOLVED] Count Certain months between two dates
    By Goose0701 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 09-25-2015, 01:23 PM
  4. [SOLVED] Count Last Days of Months Between Two Dates
    By xybadog in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 05-13-2014, 10:10 AM
  5. [SOLVED] Count number of months between two dates
    By nadeem.ansari1980 in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 03-21-2014, 02:36 PM
  6. Count Months Between Dates
    By jpgoeth in forum Excel General
    Replies: 3
    Last Post: 05-31-2007, 12:17 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1