+ Reply to Thread
Results 1 to 8 of 8

Using Weekday and CountIf functions to count days in an array

  1. #1
    Registered User
    Join Date
    03-22-2016
    Location
    USA
    MS-Off Ver
    Office: Office 13 Home: Office 16
    Posts
    22

    Using Weekday and CountIf functions to count days in an array

    Hey Guys,
    I'm trying to create a weekly summary of items due that week from a table that I've created but I cant seem to get the formula to work, even when running it as an array. I feel like I'm missing something but I can't figure it out. My first instinct is to maybe use a nested If function but I can't visualize how it would end without being incredibly lengthy and time consuming. Additionally, I would need to modify the formula every time a new line is added to the table, which doesn't make a lot of sense from a practical standpoint.

    This is the formula I tried, but it only returned a zero value when I know the correct return value should be 3.
    =COUNTIF(Table2[ARR DATE],WEEKDAY(TODAY(),2)<5)

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

    Re: Using Weekday and CountIf functions to count days in an array

    Hard to visualise this...

    Will you please attach a SMALL sample Excel workbook (10-20 rows of data is usually enough)? Please don't attach a picture of one (no-one will want to re-type all your stuff before starting).

    1. Make sure that your sample data are truly REPRESENTATIVE of your real data. The use of unrepresentative data is very frustrating and can lead to long delays in reaching a solution.

    2. Make sure that your desired solution is also shown (mock up the results manually).

    3. Make sure that all confidential information is removed first!!

    4. Try to avoid using merged cells. They cause lots of problems!

    Unfortunately the attachment icon doesn't work at the moment. So, to attach an Excel file you have to do the following: Just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.
    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

  3. #3
    Registered User
    Join Date
    03-22-2016
    Location
    USA
    MS-Off Ver
    Office: Office 13 Home: Office 16
    Posts
    22

    Re: Using Weekday and CountIf functions to count days in an array

    Quote Originally Posted by Glenn Kennedy View Post
    Hard to visualise this...

    Will you please attach a SMALL sample Excel workbook (10-20 rows of data is usually enough)? Please don't attach a picture of one (no-one will want to re-type all your stuff before starting).

    1. Make sure that your sample data are truly REPRESENTATIVE of your real data. The use of unrepresentative data is very frustrating and can lead to long delays in reaching a solution.

    2. Make sure that your desired solution is also shown (mock up the results manually).

    3. Make sure that all confidential information is removed first!!

    4. Try to avoid using merged cells. They cause lots of problems!

    Unfortunately the attachment icon doesn't work at the moment. So, to attach an Excel file you have to do the following: Just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.
    Thanks Glenn. I've attached the sample here per your instructions.
    Attached Files Attached Files
    Last edited by Mongoloid; 09-13-2017 at 04:24 PM.

  4. #4
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,396

    Re: Using Weekday and CountIf functions to count days in an array

    Try this in cell D2.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Dave

  5. #5
    Registered User
    Join Date
    03-22-2016
    Location
    USA
    MS-Off Ver
    Office: Office 13 Home: Office 16
    Posts
    22

    Re: Using Weekday and CountIf functions to count days in an array

    Thanks Dave. That worked. Can you please explain what you did so that I can modify the formula for other lengths of time, or reconfigure to include weekends?

  6. #6
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,396

    Re: Using Weekday and CountIf functions to count days in an array

    You're welcome. Glad it works.

    If I understand correctly just drop the WEEKDAY portion of the formula.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    That returns 12 in the upload.

    Try using the Evaluate Formula feature (a.k.a. Fx). Select the cell with the formula in question and subject it to Fx. It will reveal step by step how Excel calculates the formula.

    Of note: the "+" preceding the ranges are important here. The date functions are resistant to range referencing. They need to be coerced into an array. "+" is one method of doing this.
    Last edited by FlameRetired; 09-14-2017 at 05:58 PM.

  7. #7
    Registered User
    Join Date
    03-22-2016
    Location
    USA
    MS-Off Ver
    Office: Office 13 Home: Office 16
    Posts
    22

    Re: Using Weekday and CountIf functions to count days in an array

    Thanks Dave. What do the "-" symbols do for the formula, the same as the "+"?

  8. #8
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,396

    Re: Using Weekday and CountIf functions to count days in an array

    Quote Originally Posted by Mongoloid View Post
    Thanks Dave. What do the "-" symbols do for the formula, the same as the "+"?
    Glad to help.Thanks for the feedback.

    RE: "--". Somewhat. In this case they coerce TRUE/FALSE returned by the (WEEKNUM(+Table1[DUE DATE],1)=WEEKNUM($B$1,1)) part into their underlying numeric 1/0 values. This enables SUMPRODUCT sum up the TRUEs which are now 1s.

    Any mathematical operation does the same thing.
    • 1* (WEEKNUM(+Table1[DUE DATE],1)=WEEKNUM($B$1,1))
    • 0+ (WEEKNUM(+Table1[DUE DATE],1)=WEEKNUM($B$1,1))
    • (WEEKNUM(+Table1[DUE DATE],1)=WEEKNUM($B$1,1)) /1
    • and (WEEKNUM(+Table1[DUE DATE],1)=WEEKNUM($B$1,1)) ^1.


    I just prefer the double-unary "--".

    The "+" is a special case issue. Some functions do not accept ranges by default. The ranges need to be coerced into an array. The date functions all seem to fit into this category. There are others.
    Last edited by FlameRetired; 09-18-2017 at 04:29 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. Replies: 10
    Last Post: 01-03-2021, 06:24 PM
  2. Help me! I want to count the working days of worker with count and if array.
    By tuyetngapt in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-03-2013, 12:52 AM
  3. [SOLVED] Consecutive Employee Vacation Days using sumif array with frequency and column functions
    By ciaran01 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-12-2013, 10:24 AM
  4. Replies: 7
    Last Post: 09-02-2011, 08:54 PM
  5. Replies: 0
    Last Post: 05-04-2011, 06:26 PM
  6. Countif with other functions -- Median, IF, Count
    By rkrieg in forum Excel General
    Replies: 2
    Last Post: 02-01-2010, 06:24 PM
  7. Replies: 2
    Last Post: 10-29-2009, 04:52 PM
  8. Help with Count, CountIf, Sum Functions
    By Kris in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-24-2006, 02:50 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