Consulting

Results 1 to 6 of 6

Thread: Sleeper: 2 Sumproduct Function same result

  1. #1
    VBAX Regular
    Joined
    Apr 2009
    Posts
    32
    Location

    Sleeper: 2 Sumproduct Function same result

    What is the Difference Between these 2 Sumproduct Functions.

    SUMPRODUCT(--($H$2:$H$33=H2),--($I$2:$I$33=I2),--($J$2:$J$33))
    SUMPRODUCT(($H$2:$H$33=H2)*($I$2:$I$33=I2),$J$2:$J$33)
    Name City Total 1st Sumproduct 2nd Sumproduct A X 7.8 24.06 24.06 A X 6.8 24.06 24.06 A X 5.23 24.06 24.06 A X 4.23 24.06 24.06 A Y 12 12 12 D Y 24 47 47 D Y 23 47 47 G X 24.3 24.3 24.3 J Y 12 68 68 J Y 56 68 68 J X 48 112 112 J X 12 112 112 J X 23 112 112 J X 15 112 112 J X 14 112 112 M X 12 40 40 M X 13 40 40 M X 15 40 40 P Y 12 38 38 P Y 14 38 38 P Y 12 38 38 S X 16 35 35 S X 19 35 35 V Y 17 56 56 V Y 18 56 56 V Y 21 56 56 X Z 22 158 158 X Z 23 158 158 X Z 26 158 158 X Z 28 158 158 X Z 29 158 158 X Z 30 158 158


    both Give me Same Result

    What is the Difference Between "--" and "*" in these Functions

    And Which one is the Best or Sufficient.

    regards

    Hardeep kanwar

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,443
    Location
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    Xld
    i wan to be sure
    the first - to convert any Mainus to positive
    but the second Minus what do ?????????

  4. #4
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Juba
    A2 = A1 can return True or False (say it it is true). Adding -- or *1 will coerce this to a numerical value.
    -(A2=A1) = -1
    --(A2=A1) = 1
    The Double Unary therefor converts an array of True/False to an array of 1/0 which can be multiplies angainst an array of similar/other numerical values.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  5. #5
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,443
    Location
    Quote Originally Posted by Juba
    Xld
    i wan to be sure
    the first - to convert any Mainus to positive
    but the second Minus what do ?????????
    No, the first minus to coerce True/False to -1/0, the second to make it positive.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  6. #6
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    The way I always looked at it, is if you are within the same array and doing a mathematical operation, if it's a boolean return it will be coerced, thus no need for a double unary minus, or multiplied by 1, or added zero, whatever.

    Quote Originally Posted by xld
    Your website is re-directing me to some weird site...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •