+ Reply to Thread
Results 1 to 17 of 17

Embedding MAX/MIN in SUMPRODUCT Formula

  1. #1
    Registered User
    Join Date
    06-10-2014
    Location
    Centreville, Virginia (U.S.)
    MS-Off Ver
    M365 (Windows)
    Posts
    8

    Embedding MAX/MIN in SUMPRODUCT Formula

    Greetings,

    Apologies for struggling with a properly descriptive title for this post.

    I'm trying to tabulate the sum of my opportunities (A3:D6) by contract and month.

    The dollar value of an opportunity is calculated as the the $/hr * workdays that the opportunity overlaps with the given month * 8 hrs.
    The desired results are in the bottom table.

    In cell B17 I have this formula, which I think is pretty close, but is not working:
    =SUMPRODUCT((MAX(NETWORKDAYS(MAX(B$14,$C$3:$C$6), MIN(B$15,$D$3:$D$6), $H$2:$H$12),0))*($A$3:$A$6=$A17)*($B$3:$B$6)*8)

    For what it's worth, the formula below to find the number of overlapping workdays between two sets of dates, seems to work as intended:
    =MAX(NETWORKDAYS(MAX(start1,start2), MIN(end1,end2), tblHolidays),0)

    Thank you for the help!
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    10-19-2021
    Location
    Brazil
    MS-Off Ver
    Office 365 V2401 w/ Win10 Home 64 Bit
    Posts
    2,014

    Re: Embedding MAX/MIN in SUMPRODUCT Formula

    Try this.

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

  3. #3
    Registered User
    Join Date
    06-10-2014
    Location
    Centreville, Virginia (U.S.)
    MS-Off Ver
    M365 (Windows)
    Posts
    8

    Re: Embedding MAX/MIN in SUMPRODUCT Formula

    Thank you, DJunqueira, but it doesn't look like that achieves the desired output. I'm confident about this part of the formula to find the overlapping workdays: =MAX(NETWORKDAYS(MAX(start1,start2), MIN(end1,end2), tblHolidays),0).
    Again, much appreciate the assist.

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,371

    Re: Embedding MAX/MIN in SUMPRODUCT Formula

    Try explaining ne of your expected results: how EXACTLY have you calculated $168 in B25? What is the manual calculation that gets you there? If we know that, we can offer a suggestion.
    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. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  5. #5
    Registered User
    Join Date
    06-10-2014
    Location
    Centreville, Virginia (U.S.)
    MS-Off Ver
    M365 (Windows)
    Posts
    8

    Re: Embedding MAX/MIN in SUMPRODUCT Formula

    Hi Ali,

    Thank you for coaching me through this! First, I'm going to apologize, and then I'm going to hide under a rock because my manual calculations for Contract 1 were wrong.

    Please take a look at my revised file attached.

    The formula for a single opportunity is (Rev/hr) * (8 hrs/day) * the overlapping workdays between the start and end of the opportunity and the calendar month; this formula is correctly represented in B30:M31.

    However, I want the summary table (B17:M19) to show the sum of all opportunities for a given contract in the date range.

    Thank you again for your kind assistance.

    Respectfully and gratefully,
    steve

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,371

    Re: Embedding MAX/MIN in SUMPRODUCT Formula

    I'm still pretty flummoxed - sorry. Given these rates:

    AliGW on MS365 Beta Channel (Windows 11) 64 bit

    A
    B
    C
    D
    2
    Contract
    Rev/hr
    Start
    End
    3
    Contract 1
    $1.00
    01-Jan-24
    06-Jul-24
    4
    Contract 1
    $2.00
    01-May-24
    09-Dec-24
    Sheet: Sheet1

    what should the rate be for 01 May to 06 July? $1 or $2? How do I determine what to do with that overlap? Is 01 May correct, or should it in fact be 07 July?

    Sorry - I'm not really any closer and contract 1 is still $168, even though you have now said that this has been calculated wrongly. So, what should it be and why (exactly)? What is a working week?

  7. #7
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,710

    Re: Embedding MAX/MIN in SUMPRODUCT Formula

    Pl see file for all formulas.
    Table A14:M20 acts as a helper table, which is necessary. Final table is in O13:AA20
    Pl note
    Array formula should be confirmed with Ctrl+Shift+Enter keys together.
    If answere is satisfactory press * to add reputation.

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

    Re: Embedding MAX/MIN in SUMPRODUCT Formula

    @ kvsrinivasamurthy

    Your forum profile is out-of-date - please update it.

    Administrative Note:

    Where you have provided a workbook solution, please also include a clear explanation of what you've done and how (including formulae/code as approriate) in the post in question (for the benefit of members unable to download attachments).

    This is about making your assistance accessible to all.

    Thanks.

  9. #9
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,710

    Re: Embedding MAX/MIN in SUMPRODUCT Formula

    I am having 2019 version. Sometimes with the help of online I use 365 version for some problems.
    Regarding formulas used.

    In A17
    =A3:A6

    In B17 copied upto M20
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    In O17
    =UNIQUE(A17#)

    In P17 copie down to P20
    Formula: copy to clipboard
    Please Login or Register  to view this content.

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

    Re: Embedding MAX/MIN in SUMPRODUCT Formula

    Thank you.

  11. #11
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,710

    Re: Embedding MAX/MIN in SUMPRODUCT Formula

    Formula in O17 can be replaced by this formula so that formula in P17 can be avoided. No dragging of formula.
    Single entry in O17 is sufficient.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by kvsrinivasamurthy; 02-03-2024 at 07:49 AM.

  12. #12
    Registered User
    Join Date
    06-10-2014
    Location
    Centreville, Virginia (U.S.)
    MS-Off Ver
    M365 (Windows)
    Posts
    8

    Re: Embedding MAX/MIN in SUMPRODUCT Formula

    Hi Ali,

    I'm sorry for being the source of the flummoxing and much appreciate your continued willingness to assist.

    There are two separate opportunities associated w/ Contract #1. Those could be additional people, work, scope, etc., where the revenue is based on working hrs. In real life, these numbers would be much higher, but used $1 and $2 for simplicity sake.

    MY GOAL: Calculate the sum of all opportunities, per contract, per month in Table B17:M19 (without the use of a helper table).

    Contract #1, Opportunity #1 is $1/hr, per working hr, from 1 Jan - 6 Jul. There are 8 working hrs each day, M-F, subtract the holiday table.
    So, for Jan - Jun, the amt of monthly revenue associated w/ Contract #1, Opportunity #1 equals the number of workdays in ea month * 8 hrs * $1/hr
    But for Jul, there is only a 4-workday overlap w/ the dates associated w/ Opp #1, so revenue = 4 (overlapping workdays) * 8hrs * $1/hr = $32

    Contract #2, Opportunity #2 is $2/hr, per working hr, from 1 May - 9 Dec.
    And so, for May - Nov, the amt of monthly revenue associated w/ Contract #1, Opportunity #2 equals the number of workdays in ea month * 8 hrs * $2/hr
    But for Dec, there is only a 6-workday overlap w/ the dates associated w/ Opp #2, so revenue = 6 (overlapping workdays) * 8hrs * $2/hr = $96

    I'm confident I have correctly captured in B30 (and copied to M31) the formula for the amount of revenue for any given month, associated with a SINGLE opportunity, but I want the table in B17:M19 to capture the total of ALL opportunities per contract (per month), assuming the table A3:D6 is much larger in real life, covering hundreds of opportunities across many contracts.

    My (non-working) formula in B17 tries to achieve this aggregation by attempting (but failing) to SUMPRODUCT the formula that represents the revenue associated w/ a single opportunity (B30) w/ a lookup against the Contract name (A3:A6) and the start and end dates of ea month (B14:M15).

    Thank you very much.

    steve

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

    Re: Embedding MAX/MIN in SUMPRODUCT Formula

    You need to respond to the solutions offered - I'm off the case, sorry.

  14. #14
    Registered User
    Join Date
    06-10-2014
    Location
    Centreville, Virginia (U.S.)
    MS-Off Ver
    M365 (Windows)
    Posts
    8

    Re: Embedding MAX/MIN in SUMPRODUCT Formula

    Thanks so much, but I can't follow any of that.

  15. #15
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,371

    Re: Embedding MAX/MIN in SUMPRODUCT Formula

    Have you looked at the workbook offered in post #12? Does it do what you want?

  16. #16
    Registered User
    Join Date
    06-10-2014
    Location
    Centreville, Virginia (U.S.)
    MS-Off Ver
    M365 (Windows)
    Posts
    8

    Re: Embedding MAX/MIN in SUMPRODUCT Formula

    Thank you - I don't understand any of it, but it works.

  17. #17
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,371

    Re: Embedding MAX/MIN in SUMPRODUCT Formula

    Good.

    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 each of those who offered help.

+ 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: 6
    Last Post: 05-04-2022, 11:28 AM
  2. Embedding a formula into a cell
    By Jlitterio in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-30-2013, 10:32 AM
  3. Embedding SUMPRODUCT & SUMIF
    By sstyre in forum Excel General
    Replies: 3
    Last Post: 01-19-2012, 05:30 PM
  4. Embedding If Statement into SUMPRODUCT
    By rhudgins in forum Excel General
    Replies: 2
    Last Post: 01-19-2010, 06:35 PM
  5. embedding a formula
    By stephen1000 in forum Excel General
    Replies: 5
    Last Post: 03-10-2009, 08:26 AM
  6. Embedding index function in sumproduct
    By everton9 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 10-05-2007, 04:23 PM
  7. Embedding a formula
    By sixfivebeastman in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-08-2005, 03:48 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