+ Reply to Thread
Results 1 to 6 of 6

IF formula in SUMPRODUCT

  1. #1
    Registered User
    Join Date
    12-08-2009
    Location
    Munich
    MS-Off Ver
    Excel 2007
    Posts
    3

    IF formula in SUMPRODUCT

    Hi everybody,

    I'm trying to write a SUMPRODUCT formula (cell H2 in the attachment) that gives different outputs according to the value of another cell (H1), but the output values are incorrect. I suppose it's because the "else" value given in the IF formula won't be recognized as a formula but as a text. I would appreciate a lot if anybody found a solution to this problem. Thanks a lot in advance.
    Attached Files Attached Files
    Last edited by rezary; 12-09-2009 at 08:30 AM.

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,058

    Re: IF formula in SUMPRODUCT

    How about this:

    =IF(H1="ALL";SUM(C:C);SUMIF(B:B;H1;C:C))
    Never use Merged Cells in Excel

  3. #3
    Registered User
    Join Date
    12-08-2009
    Location
    Munich
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: IF formula in SUMPRODUCT

    Hi zbor,
    Thanks for your suggestion. The thing is that I want to include several conditions, as seen in the updated attachment. I guess it could be done with the SUMIFS formula, but the wanted formula is going to be entered into a lot of cells with reference to huge amounts of data. So I want to avoid nesting that many IF formulas in order to prevent the file from slowing down.
    Attached Files Attached Files

  4. #4
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,727

    Re: IF formula in SUMPRODUCT

    Try like this

    =SUMPRODUCT((data_category=J1)*(data_item=J3),(J2="All")+(data_country=J2),data_sales)

  5. #5
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,727

    Re: IF formula in SUMPRODUCT

    The above just accommodates J2 potentially being "All", if you want to allow that for J1 and J3 too then try like this

    =SUMPRODUCT((J1="All")+(data_category=J1),(J3="All")+(data_item=J3),(J2="All")+(data_country=J2), data_sales)

    Note: assumes that "All" won't appear in the data......

  6. #6
    Registered User
    Join Date
    12-08-2009
    Location
    Munich
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: IF formula in SUMPRODUCT

    Hi daddylonglegs,

    That's exactly what I was looking for. Thank you very much!

    Cheers

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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