• Sum based on Value (Excel 2003)

    Author
    Topic
    #455506

    Hi all

    I can use =SUMIF(A1:A6,”=2″) to sum all 2 in a range.
    Can SUM(IF….) do the same ? I can’t get the formula to work

    cheers

    Viewing 2 reply threads
    Author
    Replies
    • #1134363

      It’s not clear what you want. Jerry has posted one possible solution. Depending on what you want to accomplish, you might use the following array formula (confirm with Ctrl+Shift+Enter) instead:

      =SUM(IF(A1:A6=2,A1:A6))

    • #1134364

      You could use:

      =COUNTIF(A1:A6,2)*2

    • #1134396

      SUMIF needs three arguements.
      Perhaps =SUMIF(A1:A6, 2, A1:A6) will work for you.

      (The =COUNTIF(A1:A6,2)*2 is possibly faster)

      • #1134406

        If the range to test the condition on and the range to sum are equal, you can omit the third argument of SUMIF – see SUMIF.

        • #1134443

          Thanks to all.

          How does the =COUNTIF(A1:A6,2)*2 works?

          cheers

          • #1134445

            The original formula

            =SUMIF(A1:A6,”=2″)

            adds the cells in the range A1:A6 whose value equals 2. If there is 1 such cell, the sum is 2, if there are 2 such cells, their sum is 2*2 = 4, if there are 3 such cells, their sum is 3*2 = 6 etc.
            In other words, the sum is 2 times the number of cells that equal 2. COUNTIF calculates that number.

            If you had wanted to sum the cells whose value equals 37, the sum would be 37 times the number of cells that equal 37, or

            =COUNTIF(A1:A6,37)*37

            • #1134461

              Hi Hans

              Great explaination! Thanks

              cheers

            • #1134536

              1] COUNTIF can use in this way :

              =SUM(COUNTIF(A1:A6,2)*{1,1})

              2] Or, using SUMIF, and SUMPRODUCT function

              =SUMIF(A1:A6,2)

              =SUMPRODUCT((A1:A6=2)*A1:A6)

              Please take a look of this :

              SUMIF can accept the whole Column A, but SUMPRODUCT cannot.

    Viewing 2 reply threads
    Reply To: Sum based on Value (Excel 2003)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: