+ Reply to Thread
Results 1 to 7 of 7

Is it possible to have an IF inside SUMPRODUCT?

  1. #1
    Forum Contributor
    Join Date
    05-24-2006
    Location
    Los Angeles
    MS-Off Ver
    2019
    Posts
    328

    Is it possible to have an IF inside SUMPRODUCT?

    Hi,

    Is it possible to use an IF function within Sumproduct?

    I am trying to create a formula that looks like this:

    Sumproduct((RangeA)*if(A1=TRUE,RangeB,RangeC)*(RangeD))

    The actual formula looks like this:

    =SUMPRODUCT((Chart5DateAll<=EOMONTH(F$132,0))*IF(Chart5PeriodFiscalYTD=TRUE,OFFSET(Chart5DateAll,1,0)=OFFSET($F$104,0,MATCH(F$132,Chart5DateAll,0)-1),Chart5DateAll>EOMONTH(F$132,-Chart5PeriodIncrement))*OFFSET(Chart5DateAll,ROWS(F$103:F110)-1,0))

    Problem is it works without the IF function.

    Thanks,

    Lawrence
    Last edited by skysurfer; 03-10-2010 at 12:17 PM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Is it possible to have an IF inside SUMPRODUCT?

    Try confirming the formula with Ctrl+Shift+Enter.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Contributor
    Join Date
    05-24-2006
    Location
    Los Angeles
    MS-Off Ver
    2019
    Posts
    328

    Re: Is it possible to have an IF inside SUMPRODUCT?

    Quote Originally Posted by shg View Post
    Try confirming the formula with Ctrl+Shift+Enter.

    It works, but I do not understand why.

    Is there as way to make it work without turning it into an array? Concerned about slowing down the model as there are hundreds of these calcs.

    Thanks for the help!!!

    Lawrence

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Is it possible to have an IF inside SUMPRODUCT?

    It was already an array formula to all intents and purposes. Your time would be better spent making it non-volatile -- replace OFFSET with INDEX, for example -- and avoid duplicatively calculating things that could be done once in a helper cell, like the EOMONTH funtion, possibly.

  5. #5
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Is it possible to have an IF inside SUMPRODUCT?

    I agree with all of shg's points (obviously).

    I would say that if

    a) you need to keep using a SUMPRODUCT (ie you're not running XL2007 [COUNTIFS] and don't want to use 2 COUNTIFs)

    and/or

    b) you want to avoid CTRL + SHIFT + ENTER entry

    then split the formula via a pre-emptive IF, eg:

    Please Login or Register  to view this content.
    The above removes the need for CTRL + SHIFT + ENTER and the SUMPRODUCT is still calculated only once however the formula itself is obviously longer.

    Whichever route you take - as shg has already pointed out - the Volatility will generate significant overheads.
    The Volatility means the above will recalculate with every Volatile action undertaken in your model irrespective of whether or not said action has a direct impact on the precedents of your function.

    If you want help doing this I would suggest posting a sample file.
    We can see you're adjusting ranges for use with the SUMPRODUCT but from the formula alone it's hard to establish possible non-volatile (and indeed non-array/Sumproduct) alternatives.

    (SUMPRODUCTs & Arrays are "processed" in the same way - a SUMPRODUCT is not really noticeably quicker than an Array (if at all) - it's a debated topic but most agree that if a difference does exist - it's small)
    Last edited by DonkeyOte; 03-06-2010 at 04:48 AM. Reason: furnished

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Is it possible to have an IF inside SUMPRODUCT?

    Per the note at MrExcel - if you choose to x-post please have the courtesy to provide links accordingly

    http://www.mrexcel.com/forum/showthread.php?t=452969

    This applies to all forums.

  7. #7
    Forum Contributor
    Join Date
    05-24-2006
    Location
    Los Angeles
    MS-Off Ver
    2019
    Posts
    328

    Re: Is it possible to have an IF inside SUMPRODUCT?

    Quote Originally Posted by shg View Post
    It was already an array formula to all intents and purposes. Your time would be better spent making it non-volatile -- replace OFFSET with INDEX, for example -- and avoid duplicatively calculating things that could be done once in a helper cell, like the EOMONTH funtion, possibly.

    Thanks for your feedback. I've used it to resolve the issue and improve the model!

    Lawrence

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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