+ Reply to Thread
Results 1 to 15 of 15

Need to combine Sum and Count functions in a single formula

  1. #1
    Registered User
    Join Date
    08-25-2023
    Location
    Ontario, Canada
    MS-Off Ver
    Office365
    Posts
    5

    Thumbs up Need to combine Sum and Count functions in a single formula

    Good morning. for the following ranges G16:M16 and G17:M17, I need a formula that will count if G16+G17 is equal to or greater than 4, then counts as 1, to a max of 7. Context, farm workers log their time working on 2 different crops for the week: Monday: G16 crop 1, G17 crop 2; Tuesday H16 crop 1, H17 crop 2. I need to count how many days in the week they worked 4 hours or more per day, to a total of 7 days in a week.
    This has me stumped. I can't change the format of the spreadsheet or add any additional columns because it is uploaded to a 3rd party program.
    TIA

    I've added an example of what I'm trying to do. Need to adjust the formula =COUNTIF(G8:M8,">=4")+COUNTIF(G9:M9,">=4") currently in cell O8

    Edit #2 to indicate my issue appears to be solved. Thanks again!
    Attached Files Attached Files
    Last edited by 2BusyGal; 08-25-2023 at 10:48 AM. Reason: adding sample attachment

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,836

    Re: Need to combine Sum and Count functions in a single formula

    Welcome to the forum.

    There are instructions at the top of the page explaining how to attach your sample workbook (yellow banner: HOW TO ATTACH YOUR SAMPLE WORKBOOK). Screenshots are of little practical use as we cannot manipulate them.

    A good sample workbook has just 10-20 rows of representative data that has been desensitised. It also has expected results mocked up, worked examples where required, relevant cells highlighted and a few explanatory notes.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: Need to combine Sum and Count functions in a single formula

    How about
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  4. #4
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,427

    Re: Need to combine Sum and Count functions in a single formula

    Or
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,836

    Re: Need to combine Sum and Count functions in a single formula

    Is this what you mean?

    =MIN(7,COUNTIF(G8:M8,">=4")+COUNTIF(G9:M9,">=4"))

  6. #6
    Registered User
    Join Date
    08-25-2023
    Location
    Ontario, Canada
    MS-Off Ver
    Office365
    Posts
    5

    Re: Need to combine Sum and Count functions in a single formula

    I've uploaded my spreadsheet to my original post. Currently the formula in cell O8 is =COUNTIF(G8:M8,">=4")+COUNTIF(G9:M9,">=4") which with the sample data gives me a value of 10 as it is simply counting any values >+4 in the range.
    I need it to count as follows: G1+G2 = 3, therefore do not count; H1+H2=8, count as 1; I1+I2=4, count as 1; and so on for a total count of 6

  7. #7
    Registered User
    Join Date
    08-25-2023
    Location
    Ontario, Canada
    MS-Off Ver
    Office365
    Posts
    5

    Re: Need to combine Sum and Count functions in a single formula

    AliGW: no I tried that. In the case I've posted it would give me a count of 7, but the count I need is 6. For every day a worker works 4 hours or more, they have payroll deductions taken off. That is why I need the count based on actual total hours/day.

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,836

    Re: Need to combine Sum and Count functions in a single formula

    How about this?

    =LET(s,G8:M8+G9:M9,COUNT(FILTER(s,s>=4)))

    Or a tweak of the one offered by Hans:

    =SUM(N(G8:M8+G9:M9>=4))
    Last edited by AliGW; 08-25-2023 at 10:36 AM.

  9. #9
    Registered User
    Join Date
    08-25-2023
    Location
    Ontario, Canada
    MS-Off Ver
    Office365
    Posts
    5

    Re: Need to combine Sum and Count functions in a single formula

    AliGW: when I plug it into my s/sheet and adjust for the correct row #'s, I get an error that formula isn't valid and it highlights 'FILTER'

  10. #10
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,427

    Re: Need to combine Sum and Count functions in a single formula

    Did you try the formula's in Post #3 and #4?

    [These formulas are based on your text before you have added a sample sheet.]

    In your sample sheet, this formula returns 6:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by HansDouwe; 08-25-2023 at 10:42 AM.

  11. #11
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,836

    Re: Need to combine Sum and Count functions in a single formula

    Quote Originally Posted by 2BusyGal View Post
    AliGW: when I plug it into my s/sheet and adjust for the correct row #'s, I get an error that formula isn't valid and it highlights 'FILTER'
    Are you using a French locale? If you have 365, you have FILTER. This, maybe?

    =LET(s;G8:M8+G9:M9;NB(FILTRE(s;s>=4)))

  12. #12
    Registered User
    Join Date
    08-25-2023
    Location
    Ontario, Canada
    MS-Off Ver
    Office365
    Posts
    5

    Re: Need to combine Sum and Count functions in a single formula

    HansDouwe, yes I tried the formulas in 2 & 3 and they weren't working for me. But the one you just posted in 10 seems to be working fine.

    I will use =SUM(N(G8:M8+G9:M9>=4)) as it seems to have solved my issue.

    Thank you to everyone for the quick help, I really appreciate it.

  13. #13
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,836

    Re: Need to combine Sum and Count functions in a single formula

    Glad to have helped.

    If that takes care of your original question, please choose Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, if you have not already done so, you may not be aware that you can thank anyone who offered you help towards a solution for your issue by clicking the small star icon (* Add Reputation) located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of all those who offered help.

  14. #14
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: Need to combine Sum and Count functions in a single formula

    Glad to help & thanks for the feedback.

  15. #15
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,427

    Re: Need to combine Sum and Count functions in a single formula

    Thanks for your feedback and rep . Glad to have helped.
    Last edited by HansDouwe; 08-25-2023 at 12:28 PM.

+ 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] Combine multiple functions into a single Formula
    By Gulya in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 01-22-2023, 04:52 AM
  2. Combine H Lookup and SumProduct functions formula
    By Anitykk in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-16-2013, 07:24 AM
  3. How do I combine the COUNTIF and the OR functions into a single command
    By gwilymh in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-19-2012, 04:35 PM
  4. How do I combine records in a spreadsheet to a single record with a count?
    By stevenica in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-21-2011, 10:14 AM
  5. Can you combine Count + Lookup Functions?
    By thumper300zx in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-24-2011, 02:06 PM
  6. Combine These Functions to a Single Cell
    By BigMike66 in forum Excel General
    Replies: 2
    Last Post: 10-21-2009, 02:13 AM
  7. combine the two into a single formula please
    By Steved in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-07-2005, 09:05 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