Share via

sumproduct array formula not working

Anonymous
2024-05-06T11:11:14+00:00

hi,

i would like to create a formula where i calculate the total days between 2 dates per row and provide one total number. below the formula i use

=SUMPRODUCT(MAX(0; MIN(IF(($C$2:$C$7 > DATE(2024; 3; 31)) + ISBLANK($C$2:$C$7); DATE(2024; 3; 31); IF(($C$2:$C$7 < DATE(2024; 3; 1));0;$C$2:$C$7)); DATE(2024; 3; 31)) - MAX(IF($B$2:$B$7 < DATE(2024; 3; 1); DATE(2024; 3; 1);IF($B$2:$B$7 > DATE(2024; 3; 31);0; $B$2:$B$7)); DATE(2024; 3; 1)) + 1))

column B is the "start date" and column C the "end date" and i want the total days in March. should the end date in column C be blank, it needs to use the end of march as end date
below is the data im using

Start date End Date
01/02/2024 28/02/2024
07/02/2024
15/02/2024 17/03/2024
01/03/2024 06/03/2024
12/03/2024
05/04/2024 07/05/2024

appreciate the support here

gr

micky

Microsoft 365 and Office | Excel | Other | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

8 answers

Sort by: Most helpful
  1. HansV 462.6K Reputation points
    2024-05-06T14:10:24+00:00

    MIN and MAX do not return an array of values, but a single value. You want to sum an array of values.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  2. Ashish Mathur 102K Reputation points Volunteer Moderator
    2024-05-06T23:48:31+00:00

    Hi,

    In cell B12, enter this formula

    =SUM(IF(B2:B7="",DATE(2024,3,31),B2:B7)-A2:A7+1)

    Hope this helps.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2024-05-06T14:04:06+00:00

    this worked perfectly! thanks
    i just wonder why my formula didnt work

    Was this answer helpful?

    0 comments No comments
  4. HansV 462.6K Reputation points
    2024-05-06T13:31:35+00:00

    If you have Excel 2019 or older:

    =SUM(IF(IF((C2:C7>DATE(2024, 3, 31))+(C2:C7=""), DATE(2024, 3, 31), C2:C7)-IF(B2:B7<DATE(2024, 3,1), DATE(2024, 3, 1), B2:B7)<0, 0, IF((C2:C7>DATE(2024, 3, 31))+(C2:C7=""), DATE(2024, 3, 31), C2:C7)-IF(B2:B7<DATE(2024, 3,1), DATE(2024, 3, 1), B2:B7)))

    Confirm the formula by pressing Ctrl+Shift+Enter.

    If you have a newer version:

    =LET(first, DATE(2024, 3, 1), start, IF(B2:B7<first, first, B2:B7), last, DATE(2024, 3, 31), end, IF((C2:C7>last)+(C2:C7=""), last, C2:C7), difference, end-start, SUM(IF(difference<0, 0, difference)))

    You don't need Ctrl+Shift+Enter for this.

    Was this answer helpful?

    0 comments No comments
  5. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more