+ Reply to Thread
Results 1 to 24 of 24

Counting Data in the Current Month

  1. #1
    Forum Contributor
    Join Date
    03-19-2016
    Location
    Chicago, IL
    MS-Off Ver
    Office 2016 Professional
    Posts
    388

    Counting Data in the Current Month

    See the attached spreadsheet. It counts incidents and high incidents by customer. "Sheet1" references the "Log" tab. The "Log" tab allows values from the "List" Tab.

    I would like to create a formula to count:

    - Column D: Number of "Incidents" in current month (May only). Refer to Column A for that classification of "Incident".
    - Column E: Number of "High Incidents" in current month (May only). Refer to Column B for that classification of "High Incident".

    I put the expected value in the column.


    Also, when I attempt the data by the highest total (for example, by Column D where Customer2 has the most "High Incidents", the formula's don't track and the results by Customer are no longer correct. Any idea on how to fix that?
    Attached Files Attached Files

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Counting Data in the Current Month

    Hi bdav,

    This looks like a Pivot Table answer to me. See the attached and the Pivot on the Log table. This is how I'd do this problem.

    PT filter by date and count incidents.xls
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Contributor
    Join Date
    03-19-2016
    Location
    Chicago, IL
    MS-Off Ver
    Office 2016 Professional
    Posts
    388

    Re: Counting Data in the Current Month

    Quote Originally Posted by MarvinP View Post
    Hi bdav,

    This looks like a Pivot Table answer to me. See the attached and the Pivot on the Log table. This is how I'd do this problem.

    Attachment 519218
    Thank you, I will review.

    When you created the PIVOT:

    How did you select the "May" month?
    Where does the column 'total' come from?

    This looks good at first glance.

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Counting Data in the Current Month

    I put the date in the Filter and counted customers. You need to play with Pivots a bit to see how easy they are. No formulas needed!

  5. #5
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Counting Data in the Current Month

    @bdav1216

    You personals show that you have Office 2013, you post an .xls file which is Office 2003.
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  6. #6
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,189

    Re: Counting Data in the Current Month

    Try

    In D7

    =COUNTIFS(Log!$A:$A,Sheet1!$A7,Log!$C:$C,"Incident",Log!$E:$E,">=" &EOMONTH(TODAY(),-1)+1,Log!$E:$E,"<=" &EOMONTH(TODAY(),0))

    in E7

    =COUNTIFS(Log!$A:$A,Sheet1!$A7,Log!$C:$C,"High Incident",Log!$E:$E,">=" &EOMONTH(TODAY(),-1)+1,Log!$E:$E,"<=" &EOMONTH(TODAY(),0))

    You can adapt these for 3 and 6 month periods

    =COUNTIFS(Log!$A:$A,Sheet1!$A7,Log!$C:$C,"Incident",Log!$E:$E,">=" &EOMONTH(TODAY(),-3)+1,Log!$E:$E,"<=" &EOMONTH(TODAY(),0))

    will give results from beginning of March

  7. #7
    Forum Contributor
    Join Date
    03-19-2016
    Location
    Chicago, IL
    MS-Off Ver
    Office 2016 Professional
    Posts
    388

    Re: Counting Data in the Current Month

    Quote Originally Posted by MarvinP View Post
    I put the date in the Filter and counted customers. You need to play with Pivots a bit to see how easy they are. No formulas needed!
    How did you convert the 'Incident Date' values into a month value? (example 'May' vs. having every possible date being displayed).

    Also, in the 'log' tab where the data is being sourced from for the pivot table, is there a way to refresh/account for new rows of data being added?

  8. #8
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Counting Data in the Current Month

    Also, in the 'log' tab where the data is being sourced from for the pivot table, is there a way to refresh/account for new rows of data being added?
    Make a table of the data, then new data (inserted in the next row of that table) will automatic be part of the table.

    Insert => table.

    How did you convert the 'Incident Date' values into a month value? (example 'May' vs. having every possible date being displayed).
    I am not able to open the added files in this topic, so I can't see what you mean.

  9. #9
    Forum Contributor
    Join Date
    03-19-2016
    Location
    Chicago, IL
    MS-Off Ver
    Office 2016 Professional
    Posts
    388

    Re: Counting Data in the Current Month

    Basically the 'incident date' field looks like this: 05/04/2017
    The pivot filter section has only the month being displayed in the filter: May

    The pivot looks great, it's difficult to select all of the days vs. just selecting a month, but I can't figure out how that was changed.

  10. #10
    Forum Contributor
    Join Date
    03-19-2016
    Location
    Chicago, IL
    MS-Off Ver
    Office 2016 Professional
    Posts
    388

    Re: Counting Data in the Current Month

    Quote Originally Posted by oeldere View Post
    Make a table of the data, then new data (inserted in the next row of that table) will automatic be part of the table.

    Insert => table.



    I am not able to open the added files in this topic, so I can't see what you mean.
    How do I convert my data into a table? Do I still have capability to add new rows or is there some method to adding new rows to a table?

  11. #11
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Counting Data in the Current Month

    Hi bdav,

    You need to learn about Dynamic Named Ranges that expand with each new row that is added.

    http://www.ozgrid.com/Excel/DynamicRanges.htm
    http://www.contextures.com/xlNames01.html

  12. #12
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Counting Data in the Current Month

    How do I convert my data into a table?
    Insert => table.

  13. #13
    Forum Contributor
    Join Date
    03-19-2016
    Location
    Chicago, IL
    MS-Off Ver
    Office 2016 Professional
    Posts
    388

    Re: Counting Data in the Current Month

    To go back to the pivot table:

    Currently, there are dates like this:
    05/16/2017
    05/01/2017

    In the pivot example that was provided, those dates were converted to the month: 'May'.

    I have checked the formatting of the pivot and don't see how this is being converted.

    Any idea on how to update the format of the field for the pivot only? There is an example above.

  14. #14
    Forum Contributor
    Join Date
    03-19-2016
    Location
    Chicago, IL
    MS-Off Ver
    Office 2016 Professional
    Posts
    388

    Re: Counting Data in the Current Month

    One final update to the attached. When Column G of the 'Log Tab' is = 'BBB', count. If the value of Column G is equal to something other than 'BBB', do not count.

    In the attached example, there are examples in Column G of 'AAA'. Those examples should not be counted.

    I need this logic in Column B, Column C and Columns D-I, but I can get an example of Column B, Column C and Column D, I can apply the rest of the logic.

    thank you!
    Attached Files Attached Files

  15. #15
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,189

    Re: Counting Data in the Current Month

    Just add the following:

    =COUNTIFS(Log!$A:$A,Sheet1!$A7,Log!$G:$G,"BBB",Log!C:C,"High Incident")

    to each formula

  16. #16
    Forum Contributor
    Join Date
    03-19-2016
    Location
    Chicago, IL
    MS-Off Ver
    Office 2016 Professional
    Posts
    388

    Re: Counting Data in the Current Month

    Quote Originally Posted by JohnTopley View Post
    Just add the following:

    =COUNTIFS(Log!$A:$A,Sheet1!$A7,Log!$G:$G,"BBB",Log!C:C,"High Incident")

    to each formula
    Thank you! One last question. How do I also say Not Equal to "BBB" with that same formula? There are times I want to count only "BBB" and other scenario's where I want to count all other values except for "BBB" with all of the other logic the same.

  17. #17
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,189

    Re: Counting Data in the Current Month

    The "not Equal" is "<>"

  18. #18
    Forum Contributor
    Join Date
    03-19-2016
    Location
    Chicago, IL
    MS-Off Ver
    Office 2016 Professional
    Posts
    388

    Re: Counting Data in the Current Month

    Quote Originally Posted by JohnTopley View Post
    The "not Equal" is "<>"
    Log!$G:$G,"<> BBB"

    Does this look ok?

  19. #19
    Forum Contributor
    Join Date
    03-19-2016
    Location
    Chicago, IL
    MS-Off Ver
    Office 2016 Professional
    Posts
    388

    Re: Counting Data in the Current Month

    My last question is this -> When I sort the data, all of my formula's get messed up. Do I need to make an update to account for the formula when sorting?

  20. #20
    Forum Contributor
    Join Date
    03-19-2016
    Location
    Chicago, IL
    MS-Off Ver
    Office 2016 Professional
    Posts
    388

    Re: Counting Data in the Current Month

    Here are my current formula's that I am attempting to sort:

    Primary Sort is Column C of my Customers Tab:
    =COUNTIFS(Log!$A:$A,'Customers'!$A6,Log!$I:$I,"BBB",Log!$D:$D,"Incident")

    Secondary Sort is Column A of my Customers Tab where the customers are listed:
    Customer A
    Customer B

    Prior to sorting, if Customer A has a value of 3 and Customer B has a value of 5, after I sort, the values get flipped.

  21. #21
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,189

    Re: Counting Data in the Current Month

    Please post a file as all the columns have changed.

    The sorting of the columns should have no bearing on the result as it will simple match CUSTOMERS!A6 wherever this customer exits in the file.

    You need to ensure when you sort ALL columns are selected prior to sorting.

  22. #22
    Forum Contributor
    Join Date
    03-19-2016
    Location
    Chicago, IL
    MS-Off Ver
    Office 2016 Professional
    Posts
    388

    Re: Counting Data in the Current Month

    Quote Originally Posted by JohnTopley View Post
    Please post a file as all the columns have changed.

    The sorting of the columns should have no bearing on the result as it will simple match CUSTOMERS!A6 wherever this customer exits in the file.

    You need to ensure when you sort ALL columns are selected prior to sorting.
    See attached. When I attempt to sort by Column C (or any of the columns), the data is no longer linked to the customer.

    Also, my counter of non-BBB (Column D) appears to be counting ALL instances instead of just the non-BBB.

    Thank you for taking a look!
    Attached Files Attached Files

  23. #23
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,189

    Re: Counting Data in the Current Month

    Column D formula incorrect as it has additional space

    =COUNTIFS(Log!$A:$A,'BBB Customers'!$A6,Log!$I:$I,"<>BBB")

    not

    =COUNTIFS(Log!$A:$A,'BBB Customers'!$A6,Log!$I:$I,"<> BBB")

  24. #24
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,189

    Re: Counting Data in the Current Month

    Sorted works for me if you select ALL columns then select columns to sort (use Custom Sort")

+ 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. Replies: 1
    Last Post: 04-29-2016, 01:28 PM
  2. [SOLVED] Set PivotTable Filter to Current Day, Current Week, Current Month, or Current Year
    By EnigmaMatter in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-30-2014, 08:31 AM
  3. Replies: 2
    Last Post: 06-25-2014, 11:17 PM
  4. [SOLVED] Pick a cell containing current month actulas based what the current month is.
    By vanbasten007 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-10-2014, 01:17 AM
  5. [SOLVED] Auto populate cells from data in a 6 month range starting with the current month
    By ecarnley349 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-21-2012, 07:32 PM
  6. Replies: 6
    Last Post: 02-04-2012, 06:57 PM
  7. counting working days in current month
    By firefiend in forum Excel General
    Replies: 5
    Last Post: 06-14-2007, 11:05 AM

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