+ Reply to Thread
Results 1 to 6 of 6

Can I use OR in SUMIF?

  1. #1
    iampritzy
    Guest

    Can I use OR in SUMIF?

    rFor example: SUMIF(B2:B7, "Apple OR Orange", C2:C7) If it's an apple or an
    orange, sum their values in column c.
    It does not work. Can anyone help?

  2. #2
    JMB
    Guest

    RE: Can I use OR in SUMIF?

    =SUMPRODUCT(--(((B2:B7="apple")+(B2:B7="orange"))>0),C2:C7)


    "iampritzy" wrote:

    > rFor example: SUMIF(B2:B7, "Apple OR Orange", C2:C7) If it's an apple or an
    > orange, sum their values in column c.
    > It does not work. Can anyone help?


  3. #3
    bpeltzer
    Guest

    RE: Can I use OR in SUMIF?

    As long as the conditions are disjoint (they can't both be satisfied as the
    same time), just add the results of multiple sumif's:
    =sumif(b2:b7,"Apple",c2:c7)+sumif(b2:b7,"Orange",c2:c7)

    "iampritzy" wrote:

    > rFor example: SUMIF(B2:B7, "Apple OR Orange", C2:C7) If it's an apple or an
    > orange, sum their values in column c.
    > It does not work. Can anyone help?


  4. #4
    EvolBob
    Guest

    Re: Can I use OR in SUMIF?

    Long intuitive version..

    =3DSUMPRODUCT(SUMIF(B2:B7, {"Apple","Orange"},C2:C7))

    ...slightly shorter but less intuitive.

    =3DSUMPRODUCT((B2:B7=3D{"Apple","Orange"})*C2:C7)

    Hard coding the sum up values should be avoided.
    You could put them into a cell range, in this case J1 and K1, one =
    variable per cell.

    =3DSUMPRODUCT((B2:B7=3DJ1:K1)*C2:C7)

    Use J1:J2 and it wont work, the range size having to be the same and all =
    that, but for some reason it don't apply if it goes in another =
    direction, or for Sumif - go figure.

    =3DSUMPRODUCT(SUMIF(B2:B17,J1:J2,C2:C7))


    Regards
    Robert McCurdy

    "iampritzy" <iampritzy@discussions.microsoft.com> wrote in message =
    news:FB58785B-9086-402F-81B5-9BD0A16A68E5@microsoft.com...
    rFor example: SUMIF(B2:B7, "Apple OR Orange", C2:C7) If it's an apple =
    or an=20
    orange, sum their values in column c.
    It does not work. Can anyone help?

  5. #5
    iampritzy
    Guest

    Re: Can I use OR in SUMIF?

    I tried all solutions you guys provided. Thank you all.

    "EvolBob" wrote:

    > Long intuitive version..
    >
    > =SUMPRODUCT(SUMIF(B2:B7, {"Apple","Orange"},C2:C7))
    >
    > ...slightly shorter but less intuitive.
    >
    > =SUMPRODUCT((B2:B7={"Apple","Orange"})*C2:C7)
    >
    > Hard coding the sum up values should be avoided.
    > You could put them into a cell range, in this case J1 and K1, one variable per cell.
    >
    > =SUMPRODUCT((B2:B7=J1:K1)*C2:C7)
    >
    > Use J1:J2 and it wont work, the range size having to be the same and all that, but for some reason it don't apply if it goes in another direction, or for Sumif - go figure.
    >
    > =SUMPRODUCT(SUMIF(B2:B17,J1:J2,C2:C7))
    >
    >
    > Regards
    > Robert McCurdy
    >
    > "iampritzy" <iampritzy@discussions.microsoft.com> wrote in message news:FB58785B-9086-402F-81B5-9BD0A16A68E5@microsoft.com...
    > rFor example: SUMIF(B2:B7, "Apple OR Orange", C2:C7) If it's an apple or an
    > orange, sum their values in column c.
    > It does not work. Can anyone help?
    >


  6. #6
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,729
    surely simpler.....

    =SUM(SUMIF(B2:B7,{"Apple","Orange"},C2:C7))

+ 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