+ Reply to Thread
Results 1 to 17 of 17

combine IF function and SUM(COUNTIF(INDIRECT)

  1. #1
    Registered User
    Join Date
    02-21-2022
    Location
    Algeria
    MS-Off Ver
    2010
    Posts
    8

    combine IF function and SUM(COUNTIF(INDIRECT)

    Hi, All Members.

    I want to count how many days people work and filter weekend and holly days and normal days for each emplyee. this is an example of my table:

    1.jpg

    2.jpg

    3.jpg

    The problem the code it does not work as expected it counts in linier direction

    thank you in advance

    I have changed my location into Algeria and here it is the workbook
    Last edited by yougy; 02-21-2022 at 11:10 AM. Reason: uploading files

  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,458

    Re: combine IF function and SUM(COUNTIF(INDIRECT)

    Welcome to the forum.

    There are instructions at the top of the page explaining how to attach your sample workbook.

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

    Administrative Note:

    Although we value your privacy as much you do, it could be important that members have a rough idea of your location as the solutions they offer may be affected by your locale. For instance, you might in the future post questions which are related to your regional settings.

    With this in mind, please update your profile to something more precise (something such as UK, Europe, USA, UAE, etc. will suffice).

    Thank you for helping us to help you.
    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
    Registered User
    Join Date
    02-21-2022
    Location
    Algeria
    MS-Off Ver
    2010
    Posts
    8

    Re: combine IF function and SUM(COUNTIF(INDIRECT)

    Thank you AliGW I will followin the future post. and I am from Algeria

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

    Re: combine IF function and SUM(COUNTIF(INDIRECT)

    Thank you. Post the workbook here, plesae - don't open a new thread.

    Change your location in your profile from 'system' to 'Algieria'.

  5. #5
    Registered User
    Join Date
    02-21-2022
    Location
    Algeria
    MS-Off Ver
    2010
    Posts
    8

    Re: combine IF function and SUM(COUNTIF(INDIRECT)

    I could not upload the workbook here and they did not allow me to link a download link of my workbook

  6. #6
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: combine IF function and SUM(COUNTIF(INDIRECT)

    Yes you can... but you do need to follow the instructions.

    Unfortunately the attachment icon doesn't work at the moment.

    So... for a new thread (1st post), scroll to Manage Attachments

    and for a new post in your existing thread click on Go Advanced (below the Edit Window) while composing your reply, then scroll down to and click on Manage Attachments.

    In both cases, the Upload window will open. Click on Browse and navigate to (and double-click) the file icon that you want to attach, then click on Upload and then on Close this Window to return to the Edit window.

    When you have finished composing your post, click on Submit Post.
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  7. #7
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: combine IF function and SUM(COUNTIF(INDIRECT)

    Note: there are file size limits as well (suggested sample size - seeyellow banner - top is 10-20 rows of data). Files > 1Mb must be zipped or saved as xlsb... and are more likely to be ignored as manual checking is MUCH more difficult

  8. #8
    Registered User
    Join Date
    02-21-2022
    Location
    Algeria
    MS-Off Ver
    2010
    Posts
    8

    Re: combine IF function and SUM(COUNTIF(INDIRECT)

    I did as you explain
    Attached Files Attached Files

  9. #9
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: combine IF function and SUM(COUNTIF(INDIRECT)

    OK. I can see the file.

    1. Your formula is rather complicated, I think.

    2. However, you did not include any expected results... or any explanation about HOW you derived them.

    3. These are simplified versions of your current formulae, in I:

    =COUNTIFS($A:$A,$G2,$C:$C,">"&5)

    and in H

    =COUNTIFS($A:$A,$G2,$C:$C,"<="&5)

    So, what ARE your expected results, and why??
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    02-21-2022
    Location
    Algeria
    MS-Off Ver
    2010
    Posts
    8

    Re: combine IF function and SUM(COUNTIF(INDIRECT)

    Thank you very much Glenn Kennedy, it worked as expected ,but it still need some touches.

    Firstly:

    The expected result was to count how many times each name appear in range A1:A10 in relation with range C1:C10 to know how many normal days and weekends for each employee. The problem was it counts but if i choose a name from range G in location 5 or more it doesn't count. Your answer as simple but effective it did the requested and counts everything.

    I just need some touches in the Holidays Range J1:J10.
    It must be related to range B1:B10 for example if Holiday is 02/01/2022 it counts 1 in range B1:B10 for the employee from range A1:A10 that it's name in range G

    thank you inadvance

  11. #11
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: combine IF function and SUM(COUNTIF(INDIRECT)

    Where is the list of holidays? Please add them and manually add some expected answers and repost the file in THIS thread.

  12. #12
    Registered User
    Join Date
    02-21-2022
    Location
    Algeria
    MS-Off Ver
    2010
    Posts
    8

    Re: combine IF function and SUM(COUNTIF(INDIRECT)

    Ok,but you have to put in consideration that holidays can be normal days and can be a weekend so we must mins the number of holiday from the number of normal days if the holiday is a normal day and mins it from the number of weekend if the holiday is a weekend
    Attached Files Attached Files

  13. #13
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: combine IF function and SUM(COUNTIF(INDIRECT)

    OK. Change of approach.

    =IF(B2="","",IF(AND(ISNUMBER(MATCH(B2,$E$2:$E$10,0)),B2<>""),"H",IF(WEEKDAY(B2)<=5,"N",IF(WEEKDAY(B2)>=6,"W",""))))

    to define the day type... and then just use COUNTIFS, like this one:

    =COUNTIFS($A:$A,$G2,$C:$C,"H")

    see the sheet.
    Attached Files Attached Files

  14. #14
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: combine IF function and SUM(COUNTIF(INDIRECT)

    I just noticed that there is a redundant calculation in column C:

    =IF(B2="","",IF(ISNUMBER(MATCH(B2,$E$2:$E$10,0)),"H",IF(WEEKDAY(B2)<=5,"N","W")))

    Edited by GK at 10:18... another tweak to the formula.
    Attached Files Attached Files

  15. #15
    Registered User
    Join Date
    02-21-2022
    Location
    Algeria
    MS-Off Ver
    2010
    Posts
    8

    Re: combine IF function and SUM(COUNTIF(INDIRECT)

    thank you very much worked as expected I will populate it to the days of the month and see the last result.

    =IF(B2="";"";IF(AND(ISNUMBER(MATCH(B2;$E$2:$E$10;0));B2<>"");"H";IF(WEEKDAY(B2)<=5;"N";IF(WEEKDAY(B2)>=6;"W";""))))

    i understand the second part [;IF(WEEKDAY(B2)<=5;"N";IF(WEEKDAY(B2)>=6;"W";"")))]

    but the first part didn't get the idea

  16. #16
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: combine IF function and SUM(COUNTIF(INDIRECT)

    Take a look at Post 14... use it, it's simpler to follow and understand!!

    =IF(B2="","",IF(ISNUMBER(MATCH(B2,$E$2:$E$10,0)),"H",IF(WEEKDAY(B2)<=5,"N","W")))

    Black - if B2 is blank, return blank.

    red: looks to se if there is an exact match between B2 and any of the holidays. It will return the row number from E2:E10, or an error

    Orange: If it's a number... it's a holiday, so return H

    Cyan: if the weekday is <=5... it's a normal day, so return N

    Blue: otherwise return W (as there are no other possibilities).

  17. #17
    Registered User
    Join Date
    02-21-2022
    Location
    Algeria
    MS-Off Ver
    2010
    Posts
    8

    Re: combine IF function and SUM(COUNTIF(INDIRECT)

    Thanx very much

+ 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] Indirect function (I think) and countif
    By kevin_frisch in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-17-2017, 05:54 AM
  2. [SOLVED] INDIRECT function with COUNTIF
    By TheRobsterUK in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-12-2017, 10:36 AM
  3. [SOLVED] Countif and Indirect function
    By KK1234 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 11-21-2015, 01:09 PM
  4. Need Help with COUNTIF and INDIRECT function...
    By ckent0715 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 05-27-2014, 01:11 PM
  5. [SOLVED] How do you combine INDIRECT and COUNTIF?
    By ajeffres in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 05-21-2014, 02:17 PM
  6. Combine INDEX with INDIRECT + MATCH FUNCTION
    By LemonOrange in forum Excel General
    Replies: 20
    Last Post: 03-26-2014, 04:52 PM
  7. Combine ROUND and INDIRECT function
    By taniwha in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-17-2013, 01:19 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