+ Reply to Thread
Results 1 to 3 of 3

Using "--" in a SUMPRODUCT formula

  1. #1
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,785

    Using "--" in a SUMPRODUCT formula

    I saw an example in another forum that used "--" like this:

    =SUMPRODUCT(--($A$2:$A$9=$J$2),--($B$2:$B$9=$K$2),(D$2:D$9))

    What does qualifying the array expression with "--" do?

    In this case the arrays in the first two expressions (columns A and B) contain text. The formula is seeking a match for the two text columns then returning another column (D) with corresponding data.

    I do not have a specific problem to solve but am wondering about this usage.

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

    Re: Using "--" in a SUMPRODUCT formula

    -- is referred to as double unary coercion

    A Boolean True/False can be coerced to it's integer equivalent 1/0 respectively in a number of ways, the most common being:

    Please Login or Register  to view this content.
    The double unary is opted for by many as it is deemed as perhaps the more efficient of the options ... (using division is limited to specific situations - ie 1/FALSE generally leads to #DIV/0! errors)

    Some have/do argue for single unary coercion given less operations required to coerce but it means being aware how of how many "arrays" of values are being coerced - ie if the number is odd the result will be returned in the opposite sign to the correct value.

    For a good overview of SUMPRODUCT and coercion see the link in my sig. to Bob Phillips' white paper.

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,785

    Thumbs up Re: Using "--" in a SUMPRODUCT formula

    Thanks for a quick reply! I didn't realize explicit conversion was needed when the context used a boolean as an integer. The link was informational too. I have a software development background but coercion policies can vary widely......thanks again.

+ 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