+ Reply to Thread
Results 1 to 12 of 12

Calculating values but ignoring if it's a higher value than the previous one

  1. #1
    Registered User
    Join Date
    09-11-2021
    Location
    norwich, england
    MS-Off Ver
    2019
    Posts
    3

    Calculating values but ignoring if it's a higher value than the previous one

    Hi,

    I'm not sure how to do this:

    I have different files every day of the week, so I copy all the values into one sheet and what I want to do is to calculate the total but ignore if the value in the next cell is higher than the prevoius one as it is unknown. Please see the file attached.

    Any suggestions are welcome.

    Thanks
    Attached Files Attached Files
    Last edited by anik99; 09-11-2021 at 03:02 PM. Reason: upload error fix

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    31,171

    Re: Calculating values but ignoring if it's a higher value than the previous one

    There are instructions at the top of the page explaining how to attach your sample workbook.

  3. #3
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    31,171

    Re: Calculating values but ignoring if it's a higher value than the previous one

    As you offered no explanation of the required calculation I am "guessing" from what I recall from your first post:

    =SUM(IF(B2:G2-C2:H2>0,B2:G2-C2:H2,0))

    Enter with Ctrl+shift+Enter

  4. #4
    Registered User
    Join Date
    09-11-2021
    Location
    norwich, england
    MS-Off Ver
    2019
    Posts
    3

    Re: Calculating values but ignoring if it's a higher value than the previous one

    This is the formula from the second row:

    =(B2-C2)+(C2-D2)+(D2-E2)+(E2-F2)+(F2-G2)+(G2-H2)

    Where:

    B2=100
    C2=97

    D2=65
    E2=223

    F2=211
    G2=150
    H2=120

    However, the (D2-E2) must be ignored in the formula as the E2 is greater than D2. The total should be 138 or (3)+(32)+(0)+(12)+(61)+(30)

    This is just a simple template in which I have only 7 columns but in fact they can be hundreds or thousands. I hope this makes sense.

    Thanks

  5. #5
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    31,171

    Re: Calculating values but ignoring if it's a higher value than the previous one

    See attached: now has Joseph's SUMPRODUCT added
    Attached Files Attached Files
    Last edited by JohnTopley; 09-12-2021 at 01:07 AM.

  6. #6
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2019
    Posts
    4,542

    Re: Calculating values but ignoring if it's a higher value than the previous one

    Alternatively, =SUMPRODUCT((B2:G2-C2:H2)*(B2:G2>C2:H2))

  7. #7
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    31,171

    Re: Calculating values but ignoring if it's a higher value than the previous one

    @josephteh: I started down the SUMPRODUCT route but it must have been late in the day so it didn't click!

    @anik9: use Joseph's SUMPRODUCT solution!

  8. #8
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2019
    Posts
    4,542

    Re: Calculating values but ignoring if it's a higher value than the previous one

    @ JohnTopley.. haha.. it's 1pm Singapore time. I am well awake! My suggestion is to use both formulas. One main, and one as a checksum. That's what I usually do when I got multiple solutions.

  9. #9
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    31,171

    Re: Calculating values but ignoring if it's a higher value than the previous one

    @joseph: about 06:30 am here in the UK ... and on the forum: what a sad man I am!!!

  10. #10
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2019
    Posts
    4,542

    Re: Calculating values but ignoring if it's a higher value than the previous one

    No no no.. you are nothing like a sad man. You are a giant in Excel. And it's your passion in helping fellow forum members like myself that helps me improve my Excel skills tremendously! You have helped me solved many problems. For that, I am forever grateful.

  11. #11
    Registered User
    Join Date
    09-11-2021
    Location
    norwich, england
    MS-Off Ver
    2019
    Posts
    3

    Re: Calculating values but ignoring if it's a higher value than the previous one

    Thanks guys for the help. Is it going to work with hundreds or thousands of columns and rows, whatever is in the spreadsheet basically, as I see it's limited to what's in the test file? I'm trying to find the logic in order to explain to a friend who may be able to write a script based of this logic. Thanks

  12. #12
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2019
    Posts
    4,542

    Re: Calculating values but ignoring if it's a higher value than the previous one

    Yes, both formulas are going to work perfectly for hundreds and thousands of columns and rows, as long as you cover the columns correctly.

+ 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] Calculating rolling average ignoring 0 values
    By Whitz in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-07-2024, 05:51 PM
  2. Calculating of 1st and 2nd higher values
    By oulyas in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-17-2021, 07:38 AM
  3. [SOLVED] Formatting Adjacent Values if They Are higher/Lower Than Previous Column
    By theexcelnovice123 in forum Excel General
    Replies: 5
    Last Post: 07-09-2020, 05:47 AM
  4. Calculating Standard Deviation using IF and ignoring N/A values
    By sroh in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-19-2015, 12:25 PM
  5. Replies: 2
    Last Post: 05-31-2010, 03:23 PM
  6. Replies: 4
    Last Post: 07-23-2009, 03:18 PM
  7. Max and min, ignoring previous values
    By pduubb in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-21-2008, 08:23 AM

Tags for this Thread

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