+ Reply to Thread
Results 1 to 17 of 17

Countifs with multiple criteria in single criteria range

  1. #1
    Registered User
    Join Date
    12-01-2016
    Location
    Pune, Maharashtra, India
    MS-Off Ver
    Microsoft Office 2016
    Posts
    13

    Countifs with multiple criteria in single criteria range

    Dear All,

    I have worksheet in which I am calculating Days Worked and Over Time.

    I have single criteria range with multiple criteria e.g. criteria "P" has value 1, criteria "PP" has value PP*2,
    criteria "P1" has value P1*0.125 then how to define it?

    PP = 8 hrs regular duty + 8 hrs OT = 16 hrs
    P = 8 hrs regular duty
    P1 = 8 hrs regular duty + 1 hrs OT = 9 hrs
    P2 = 8 hrs regular duty + 2 hrs OT = 10 hrs and so on......

    I used the formula =SUM(COUNTIF(F8:AJ8,{"PP","P","P1","P2","P3","P4","P5","P6","P7"})), but it is not giving me the result what I want.
    Means how to define "PP"*2, P1*0.125 ........?

    Please help.

    Thanx in advance.

    Suhas

  2. #2
    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,182

    Re: Countifs with multiple criteria in single criteria range

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

  3. #3
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: Countifs with multiple criteria in single criteria range

    What do the cells contain? Just one of the codes PP, P, or Pn where n is the number of extra hours worked?
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  4. #4
    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,182

    Re: Countifs with multiple criteria in single criteria range

    Using a table below in A2:C10:

    Code Regular OT
    P 8 0
    P1 8 1
    P2 8 2
    P3 8 3
    P4 8 4
    P5 8 5
    P6 8 6
    P7 8 7
    PP 8 8

    this gives TOTAL hours based on codes in F8:AJ8

    =SUMPRODUCT((F8:AJ8=$A$2:$A$10)*(($B$2:$B$10)+($C$2:$C$10)))

    You could also combine regular hours and OT in column B so you have 8,9,10 etc

    =SUMPRODUCT((F8:AJ8=$A$2:$A$10)*($B$2:$B$10))

    Is this what you require??

  5. #5
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,463

    Re: Countifs with multiple criteria in single criteria range

    Try:
    =SUMPRODUCT(LEN(F8:AJ8)-LEN(SUBSTITUTE(F8:AJ8,"P","")))*8+SUMPRODUCT(SUBSTITUTE(F8:AJ8,"P",0)+0)

    With first SUMPRODUCT to count "P" then multiply 8
    second one to sum single hours
    Quang PT

  6. #6
    Registered User
    Join Date
    12-01-2016
    Location
    Pune, Maharashtra, India
    MS-Off Ver
    Microsoft Office 2016
    Posts
    13

    Re: Countifs with multiple criteria in single criteria range

    Hi John Sir,
    Thanx very much for reply.

    I am attaching my excel file in which I described what I want.

    File Name - Duty+OT Calculation.xlsx

    Please give the solution.

    Suhas
    Attached Files Attached Files

  7. #7
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Countifs with multiple criteria in single criteria range

    Ak5
    Please Login or Register  to view this content.
    al5
    Please Login or Register  to view this content.
    am5
    Please Login or Register  to view this content.
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  8. #8
    Registered User
    Join Date
    12-01-2016
    Location
    Pune, Maharashtra, India
    MS-Off Ver
    Microsoft Office 2016
    Posts
    13

    Re: Countifs with multiple criteria in single criteria range

    Bebo Sir,

    Formula result is 296 hrs. means 31 Days regular Duty & 6 Days Over Time. So my AK5 Cell should display 31 days i.e. 248 hrs., Cell AL5 should display 6 days i.e. 48 hrs. and Cell AM5 should display actual hours (applicable when Over Time is less than 8 hrs i.e. 1 day). File attached herewith.

  9. #9
    Registered User
    Join Date
    12-01-2016
    Location
    Pune, Maharashtra, India
    MS-Off Ver
    Microsoft Office 2016
    Posts
    13

    Re: Countifs with multiple criteria in single criteria range

    Bebo Sir,

    Formula result is 296 hrs. means 31 Days regular Duty & 6 Days Over Time.
    So my AK5 Cell should display 31 days i.e. 248 hrs., Cell AL5 should display 6 days i.e. 48 hrs. and
    Cell AM5 should display actual hours (applicable when Over Time is less than 8 hrs i.e. 1 day). File attached herewith.

  10. #10
    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,182

    Re: Countifs with multiple criteria in single criteria range

    Formulae are same as given previously.

    AL5= Total OT HOURS

    AM5= Total hours including OT
    Attached Files Attached Files

  11. #11
    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,182

    Re: Countifs with multiple criteria in single criteria range

    Modified AM

    =IF($AK5<30,0,SUMPRODUCT(($F5:$AJ5=$AR$2:$AR$10)*($AS$2:$AS$10)))

    gives REGULAR hours

  12. #12
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,908

    Re: Countifs with multiple criteria in single criteria range

    Or cell AM5:

    =SUMPRODUCT(--MID(SUBSTITUTE(F5:AJ5&0,"P",8),{1;2},1))

  13. #13
    Registered User
    Join Date
    12-01-2016
    Location
    Pune, Maharashtra, India
    MS-Off Ver
    Microsoft Office 2016
    Posts
    13

    Re: Countifs with multiple criteria in single criteria range

    Hi John Sir,

    Thanx for reply, seen the attached file, but that is not what I deserved.

    What I want is as below -

    AK is no. of days i.e. 31 or 30 (month-wise) - means in this case AK5 should display 31 (days)

    AL is no. of days i.e. If an employee worked more than total 248 hours (31 days * 8), it will be calculated as OT - means in this case AL5 should display 6 (days) (48 hrs / 8 hrs)

    AND AM is no. of hours i.e. If an employee worked more than total 248 hours i.e. 31 days and he worked extra 2 hours only then AK5 should display 31 (days), AL5 should display 0 (days) and AM5 should display 2 (hrs.). If worked extra 10 hrs., then AK5 should display 31 (days), AL5 should display 1 day (i.e. 8 hrs.) and AM5 should display 2 hrs.


    Thanking you.

    Suhas

  14. #14
    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,182

    Re: Countifs with multiple criteria in single criteria range

    AK5 DOES display 31 and it is not too difficult to divide the result in AL5 by 8!!!

    What is the logic of having OT in DAYS in AL but hours in AM??

    and what about TOTAL??? is it Days or Hours ?

    And what about a 30 day month? Is number of hours now 240?

    I'll leave you to work out these very simple calculations.
    Last edited by JohnTopley; 12-01-2016 at 08:32 AM.

  15. #15
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Countifs with multiple criteria in single criteria range

    Where do you mentioned the Month whether it was October or November

  16. #16
    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,182

    Re: Countifs with multiple criteria in single criteria range

    @nflsales: Good point - incomplete specification by the OP!

  17. #17
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,463

    Re: Countifs with multiple criteria in single criteria range

    See attachment.

    Try to define month and year in other cells.

    Array formula must be confirmed by Ctrl-shift-enter
    Attached Files Attached Files

+ 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. Countifs with multiple criteria in single criteria range
    By MCP313 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 12-01-2016, 03:51 AM
  2. Countifs with multiple criteria and data range
    By Pritirus in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-21-2016, 01:18 PM
  3. [SOLVED] COUNTIFS with multiple criteria in the same criteria range
    By Faridwahidi in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-23-2015, 01:04 PM
  4. [SOLVED] COUNTIFS multiple criteria (date range & text)
    By jholiday78 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-30-2014, 06:36 PM
  5. [SOLVED] Using COUNTIFS, counting more than one value in a single criteria range
    By litesnsirens in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-18-2014, 09:07 PM
  6. COUNTIFS with Multiple Criteria in One Range
    By mphillips in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-19-2013, 02:43 PM
  7. Countifs with multiple criteria in a single range
    By Wolfpackfan320 in forum Excel General
    Replies: 1
    Last Post: 02-27-2012, 04:54 PM

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