+ Reply to Thread
Results 1 to 11 of 11

How to sum up the values of column A if values are greater than column B in the same row?

  1. #1
    Registered User
    Join Date
    11-24-2017
    Location
    London
    MS-Off Ver
    2013
    Posts
    4

    How to sum up the values of column A if values are greater than column B in the same row?

    I want to sum up the values of Column A if its value is greater than the value in Column B in the same row.

    A B
    - -
    6
    2 1
    3 6
    2
    4 6
    1 1

    In this case, the sum should be 6 + 2 = 8

    Any advice on how to derive the formula?

    Many thanks!

  2. #2
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: How to sum up the values of column A if values are greater than column B in the same r

    Try like this

    =SUMPRODUCT((A2:A10>B2:B10)+0,A2:A10)
    Last edited by daddylonglegs; 11-24-2017 at 06:21 PM.
    Audere est facere

  3. #3
    Registered User
    Join Date
    11-24-2017
    Location
    London
    MS-Off Ver
    2013
    Posts
    4

    Re: How to sum up the values of column A if values are greater than column B in the same r

    Thank you so much.
    How about if need to add more one condition?
    Sum up if Column Column C (Date) contains "17" only?

    A B C
    - - -
    6 05-17
    2 1 04-17
    3 6 03-16
    2 02-14
    4 6 01-15
    1 1 05-12


    I tried this one. But it does not work. =SUMPRODUCT((A2:A10>B2:B10)*(C2:C10="*17*"),A2:A10)

    Any advice?

  4. #4
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: How to sum up the values of column A if values are greater than column B in the same r

    maybe this one:
    =SUMPRODUCT((A2:A7>B2:B7)*(RIGHT(C2:C7,2)="17"),A2:A7)
    or
    =SUMPRODUCT((A2:A7>B2:B7)*(--RIGHT(C2:C7,2)=17),A2:A7)

  5. #5
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: How to sum up the values of column A if values are greater than column B in the same r

    If column C contains true dates then try using YEAR function like this:

    =SUMPRODUCT((A2:A10>B2:B10)*(YEAR(C2:C10)=2017),A2:A10)

  6. #6
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: How to sum up the values of column A if values are greater than column B in the same r

    or for date/not date
    =SUM((A2:A7>B2:B7)*IF(ISNUMBER(C2:C7),YEAR(C2:C7)=2017,--RIGHT(C2:C7,2)=17)*A2:A7) with CSE
    but
    =SUMPRODUCT((A2:A10>B2:B10)*(YEAR(C2:C10)=2017)*A2:A10) works with text and numbers
    Last edited by sandy666; 11-24-2017 at 09:50 PM.

  7. #7
    Registered User
    Join Date
    11-24-2017
    Location
    London
    MS-Off Ver
    2013
    Posts
    4

    Re: How to sum up the values of column A if values are greater than column B in the same r

    Thank you for the advice. Column C contains true dates.
    =SUMPRODUCT((A2:A10>B2:B10)*(YEAR(C2:C10)=2017),A2:A10)

    This one works well in a test-spreadsheet (Left-hand side). But I can't understand why it does not work another spreadsheet (Right-hand side)
    The top screenshots show the formula used. And the bottom ones show the outcomes.
    Screenshot - 2.png.

    Any advice what went wrong?

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,460

    Re: How to sum up the values of column A if values are greater than column B in the same r

    Will you please attach a sample Excel workbook? We are not able to work with or manipulate a picture of one and nobody wants to have to recreate your data from scratch.

    1. Make sure that your sample data are REPRESENTATIVE of your real data. The use of unrepresentative data is very frustrating and can lead to long delays in reaching a solution.

    2. Make sure that your desired results are also shown (mock up the results manually).

    3. Make sure that all confidential data is removed or replaced with dummy data first (e.g. names, addresses, E-mails, etc.).

    4. Try to avoid using merged cells as they cause lots of problems.

    Unfortunately the attachment icon doesn't work at the moment, so to attach an Excel file you have to do the following: just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.

    Please pay particular attention to point 2 (above): without an idea of your intended outcomes, it is often very difficult to offer appropriate advice.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  9. #9
    Forum Expert shukla.ankur281190's Avatar
    Join Date
    05-17-2014
    Location
    Lucknow, India
    MS-Off Ver
    Office 365
    Posts
    3,935

    Re: How to sum up the values of column A if values are greater than column B in the same r

    #VALUE! -Incorrent Data Types. Check is there any value is in text? You check yourself. Press Alt-T-U-F evaluate the formula and slowly press enter and see which part of formula gives you error.
    If I helped, Don't forget to add reputation (click on the little star ★ at bottom of this post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)

  10. #10
    Registered User
    Join Date
    11-24-2017
    Location
    London
    MS-Off Ver
    2013
    Posts
    4

    Re: How to sum up the values of column A if values are greater than column B in the same r

    Sorry for uploading the images earlier, and know what to do next time.
    And thanks for everyone's advice. I checked the Data Types. Some of the fields contain "-". So I deleted them and solved the issue.

  11. #11
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: How to sum up the values of column A if values are greater than column B in the same r

    If that takes care of your original question, & to say Thanks, please click on Add Reputtion (bottom left corner of the post of the person(s) who helped you)
    then select Thread Tools from the menu (top right corner of your thread) and mark this thread as SOLVED.
    If you did it already - ignore it.
    Thank you.

+ 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] Range of values greater than particular column's values
    By LesliePrabakar in forum Excel Formulas & Functions
    Replies: 20
    Last Post: 04-11-2017, 08:43 AM
  2. [SOLVED] Need help retrieving only values greater than 1 lac values in a column
    By msb15 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-13-2017, 02:24 PM
  3. [SOLVED] count values greater 2 or greater in a column.
    By ammartino44 in forum Excel General
    Replies: 3
    Last Post: 09-16-2014, 07:05 PM
  4. [SOLVED] Sum values in one column when values in another column are greater than zero
    By mstrauss in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 03-05-2014, 03:33 PM
  5. Counting values greater than or equal to those in another column
    By andyr85 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-26-2010, 04:15 PM
  6. [SOLVED] How do I search an array for values in a column greater than zero
    By letsagmj in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 07-25-2006, 09:45 PM
  7. [SOLVED] Advanced Filter for Values in Column M greater than Values in Colu
    By SteveC in forum Excel General
    Replies: 3
    Last Post: 05-02-2006, 03:00 PM

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