+ Reply to Thread
Results 1 to 6 of 6

Sumproduct(--

  1. #1
    Forum Contributor
    Join Date
    07-16-2015
    Location
    Aberdeen, Scotland
    MS-Off Ver
    Excel 2010
    Posts
    121

    Sumproduct(--

    Hi All

    Quite often when trailing through the posts I come across the above, I have spent time on the internet looking for an explanation with no success so would appreciate if someone with the knowledge could explain when you would use "--" and why? I am familiar with Sumproduct but the double dash has me stumped.

    This is the most recent sample I saw =SUMPRODUCT(--(MOD($A$1:$A$19,2)=0)) for counting even numbers.

    Thanks

    George

  2. #2
    Valued Forum Contributor WasWodge's Avatar
    Join Date
    08-02-2010
    Location
    Hampshire,England
    MS-Off Ver
    Office 365 and Office 2010
    Posts
    882

    Re: Sumproduct(--

    It is a double unary operator to convert true and false to 1 an 0 respectively. See Format of Sumproduct in the link below.

    http://www.xldynamic.com/source/xld....CT.html#format
    If my solution worked (or not) please let me know. If your question is answered then please remember to mark it solved

    Computers are like air conditioners. They work fine until you start opening windows. ~Author Unknown

  3. #3
    Forum Expert
    Join Date
    09-01-2012
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    2,844

    Re: Sumproduct(--

    Sumproduct don't like True and False. -- Converts it into 1 and 0. Multiplying by 1 does the same thing but I guess -- is quicker.
    <----- If you were helped by my posts you can say "Thank you" by clicking the star symbol down to the left

    If the problem is solved, finish of the thread by clicking SOLVED under Thread Tools
    I don't wish to leave you with no answer, yet I sometimes miss posts. If you feel I forgot you, remind me with a PM or just bump the thread.

  4. #4
    Forum Contributor
    Join Date
    07-16-2015
    Location
    Aberdeen, Scotland
    MS-Off Ver
    Excel 2010
    Posts
    121

    Re: Sumproduct(--

    Hi WasWodge your link is very informative and a great help.

    Thanks to all who responded.



    "Education is the salvation of Ignorance"

  5. #5
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Sumproduct(--

    =-1 turns 1 into -1
    =--1 turns 1 into 1

    =+False results in False
    =+True results in True

    =-False results in 0
    =--False results in 0
    =-True results in -1
    =--True results in 1

    =N(True) results in 1
    =N(False) results in 0

    =1*False results in 0
    =1*True results in 1

    =False/1 result in 0
    =True/1 tesults in 1

    =false^1 results in 0
    =True^1 results in 1

    If you want the result 0 if false and 1 if true, you can use
    = --(condition)
    = N(condition)
    =1*(condition)
    etc.
    Last edited by snb; 06-23-2016 at 03:19 AM.



  6. #6
    Forum Contributor
    Join Date
    07-16-2015
    Location
    Aberdeen, Scotland
    MS-Off Ver
    Excel 2010
    Posts
    121

    Re: Sumproduct(--

    Hi SNB

    Nice one I understand it all by relating it to Boolean algebra its all logic

    Thanks

+ 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. [SOLVED] Use sumproduct to further parse a sumproduct calculation
    By Araise in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-19-2015, 08:17 PM
  2. Count SUMPRODUCT Members / Average of SUMPRODUCT
    By Shingaru in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-10-2014, 03:59 PM
  3. Replies: 1
    Last Post: 05-19-2012, 02:54 AM
  4. Replies: 5
    Last Post: 04-20-2012, 08:54 AM
  5. Replies: 6
    Last Post: 03-09-2011, 08:01 AM
  6. Subtract Sumproduct from a sumproduct
    By Prcntrygrl in forum Excel General
    Replies: 6
    Last Post: 01-17-2011, 02:34 PM
  7. Using a SumProduct Count to find a SumProduct Total?
    By XL021710 in forum Excel General
    Replies: 3
    Last Post: 02-18-2010, 08:31 AM

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