+ Reply to Thread
Results 1 to 4 of 4

using the OR function in arrays

  1. #1
    Registered User
    Join Date
    06-29-2007
    Posts
    10

    using the OR function in arrays

    I'd like to total the number of UNITS in an array if the customer is Steve or Sally. I've tried the following

    {=SUM(IF((product="car")*(color="red")*OR(customer="Steve",customer="Sally"),UNITS,0))}

    the function

    {=SUM(IF((product="car")*(color="red")*(customer="Steve"),UNITS,0))}

    gives me the number purchased by Steve. I'd like the number purchased by either Steve or Sally.

    I thought the OR might work, but it apparently gets evaluated as TRUE and everything in the UNITS column gets summed...

    Any suggestions? Thanks!
    Last edited by BobDaBuilder; 04-15-2008 at 05:11 PM.

  2. #2
    Forum Contributor Portuga's Avatar
    Join Date
    02-20-2004
    Location
    Portugal
    MS-Off Ver
    365
    Posts
    852
    Sum both values:

    Please Login or Register  to view this content.
    If you found the solution to your question. Mark the thread as "Solved"
    Thank everyone that helped you with a valid solution by clicking on their

    There is no such thing as a problem, only a temporary lack of a solution

  3. #3
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,723
    OR function only returns a single result not an array of results to match your array/range. I'd use SUMPRODUCT to avoid CTRL+SHIFT+ENTER, i.e.

    =SUMPRODUCT((product="car")*(color="red")*(( customer ="Steve")+(customer="Sally")),UNITS)

  4. #4
    Registered User
    Join Date
    06-29-2007
    Posts
    10
    Quote Originally Posted by daddylonglegs
    OR function only returns a single result not an array of results to match your array/range. I'd use SUMPRODUCT to avoid CTRL+SHIFT+ENTER, i.e.

    =SUMPRODUCT((product="car")*(color="red")*(( customer ="Steve")+(customer="Sally")),UNITS)
    Wow. I had not seen SUMPRODUCT used this way before. Thanks!

+ 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