+ Reply to Thread
Results 1 to 6 of 6

Calculate values in col B based on value in col B but only calculate final 5 instances

  1. #1
    Registered User
    Join Date
    11-04-2013
    Location
    Staffordshire, England
    MS-Off Ver
    Excel 2007
    Posts
    3

    Calculate values in col B based on value in col B but only calculate final 5 instances

    Hi,

    I'm trying to calculate the total value of the last 5 entries where the letter equals A. The table below shows 6 A's and their total value = 13. I would like to automatically calculate the value of the last five instances of A.

    I've used a formula to calculate the sum of values where the letter equals A (=SUMIF(A:A,"A",B:B)) and I've got a forumla which calculates the value of the last 5 rows (=SUM(OFFSET(B1,COUNTA(B1:B18)-5,0,20,1))) , I now need a way of combining these. Any sugggestions?

    Letter Value

    A 2
    B 4
    C 5
    A 1
    B 2
    C 3
    A 4
    B 3
    C 2
    A 2
    B 4
    C 4
    A 3
    B 1
    C 2
    A 1
    B 3
    C 4

  2. #2
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Calculate values in col B based on value in col B but only calculate final 5 instances

    Hi,

    Assuming the data you give above is in A1:B19 (with headers in row 1), try this array formula:

    =SUM(IF(ROW(A2:A19)=LARGE(IF(A2:A19="A",ROW(A2:A19)),{1,2,3,4,5}),B2:B19))

    Edit: you don't say what you want the result to be if there are less than 5 entries with an "A" in column A (this formula will currently return an error).

    Regards
    Last edited by XOR LX; 11-04-2013 at 11:40 AM.
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  3. #3
    Registered User
    Join Date
    11-04-2013
    Location
    Staffordshire, England
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Calculate values in col B based on value in col B but only calculate final 5 instances

    Hi,

    Thanks for the response.

    Sorry I meant I had 13 for all 6 A's but you're right the value is 11 for the last 5.

    I've tried your formula but it just shows #NUM... any ideas?

    Many thanks

  4. #4
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Calculate values in col B based on value in col B but only calculate final 5 instances

    Perhaps you missed the large, emboldened part about this being an array formula?

    Regards

  5. #5
    Registered User
    Join Date
    11-04-2013
    Location
    Staffordshire, England
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Calculate values in col B based on value in col B but only calculate final 5 instances

    Thanks, I'm fairly new to excel forumals so didn't realise I had to CTRL+SHIFT+ENTER for an array formula.

    There will never been an instance when there are less than 5 A's.

    It's working now so thanks very much.

  6. #6
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Calculate values in col B based on value in col B but only calculate final 5 instances

    You're welcome.

+ 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] Calculate SUM, based on multiple instances of a word
    By her.rockstar in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-11-2013, 11:23 AM
  2. How to calculate final sale price
    By ascottbag in forum Excel General
    Replies: 0
    Last Post: 01-29-2012, 10:48 PM
  3. Calculate eBay Final Value Fees
    By foxtrot57 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-02-2008, 07:58 PM
  4. [SOLVED] How do I calculate cost of raw materials to final product?
    By just desserts in forum Excel General
    Replies: 2
    Last Post: 01-28-2006, 03:20 PM
  5. How do I calculate the final pmt required to meet a target IRR?
    By Alex in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 10-08-2005, 11:05 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