+ Reply to Thread
Results 1 to 22 of 22

Calculate sum based on partial text match and latest date

  1. #1
    Registered User
    Join Date
    06-17-2014
    Location
    Guilford, CT
    MS-Off Ver
    2003
    Posts
    4

    Calculate sum based on partial text match and latest date

    Hi,

    I need a formula to do a partial text match on column B to find all rows that contain "825-CL-A", then sum column C for all applicable rows with the latest date. In this example the result should be "4.25 + 6.50 = 10.75". I'm using Excel 2003 for this project. Thanks for in advance for any help.

    A B C
    7/1/2012 0:00 825-CL-A-41091-REG 4.00
    7/1/2012 0:00 825-CL-A-41091-REG 6.25
    7/1/2013 0:00 825-CL-A-41456-REG 4.25
    7/1/2013 0:00 825-CL-A-41456-REG 6.50
    1/1/2014 0:00 825-CL-A-41640-REG 4.25
    1/1/2014 0:00 825-CL-A-41640-REG 6.50
    3/1/2014 0:00 825-CL-E-41699-REG 3.00
    3/1/2014 0:00 825-CL-E-41699-REG 4.00

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Calculate sum based on partial text match and latest date

    Hi - please see example attached
    Attached Files Attached Files

  3. #3
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: Calculate sum based on partial text match and latest date

    Try this regular formula

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  4. #4
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Calculate sum based on partial text match and latest date

    @sktneer,

    I originally tried something along those lines but found It gave the wrong answer, if, for example, I changed A7 in your example to 01/01/2014

    Maybe this for a non-array version?
    =SUMPRODUCT(--(A1:A8=MAX(INDEX(ISNUMBER(SEARCH("825-CL-A",B1:B8))*A1:A8,0))),--ISNUMBER(SEARCH("825-CL-A",B1:B8)),C1:C8)

  5. #5
    Registered User
    Join Date
    06-17-2014
    Location
    Guilford, CT
    MS-Off Ver
    2003
    Posts
    4

    Re: Calculate sum based on partial text match and latest date

    Thanks for your quick response. When I tried your formula I realized an oversight on my part. The summed total was too high, I was getting 26.88 instead of 10.75. I discovered two additional rows that were meeting my search criteria but should not have been included, so I need to refine the partial search criteria more closely. I need to find the rows that start with the text string "825-CL-A" in column B but also end with text string "REG" in column B.

    A B C
    7/1/2012 0:00 825-CL-A-41091-REG 4.00
    7/1/2012 0:00 825-CL-A-41091-REG 6.25
    7/1/2013 0:00 825-CL-A-41456-REG 4.25
    7/1/2013 0:00 825-CL-A-41456-REG 6.50
    1/1/2014 0:00 825-CL-A-41640-REG 4.25
    1/1/2014 0:00 825-CL-A-41640-REG 6.50
    1/1/2014 0:00 825-CL-A-41640-OT 6.38
    1/1/2014 0:00 825-CL-A-41640-OT 9.75
    3/1/2014 0:00 825-CL-E-41699-REG 3.00
    3/1/2014 0:00 825-CL-E-41699-REG 4.00

  6. #6
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Calculate sum based on partial text match and latest date

    =SUMPRODUCT(IF(A1:A8=MAX(IF(LEFT(B1:B8,8)="825-CL-A",A1:A8,0)*IF(RIGHT(B1:B8,3)="REG",1,0)),C1:C8,0),(--NOT(ISERROR(SEARCH("825-CL-A",B1:B8)))))

    as an array formula (confirm with ctrl+shift+enter) to replace the formula in E1 in my example attached to post #2

  7. #7
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: Calculate sum based on partial text match and latest date

    @ragulduy
    Very good point. I think in that case the formula may be like this (apart from one you suggested in your last reply)

    Please Login or Register  to view this content.
    Is that ok?

    Or simply this..

    Please Login or Register  to view this content.
    Last edited by sktneer; 06-19-2014 at 10:05 AM.

  8. #8
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Calculate sum based on partial text match and latest date

    One way...

    Data Range
    A
    B
    C
    D
    E
    1
    Date
    Item
    Value
    2
    7/1/2012 0:00
    825-CL-A-41091-REG
    4
    ------
    825-CL-A
    3
    7/1/2012 0:00
    825-CL-A-41091-REG
    6.25
    10.75
    4
    7/1/2013 0:00
    825-CL-A-41456-REG
    4.25
    5
    7/1/2013 0:00
    825-CL-A-41456-REG
    6.5
    6
    1/1/2014 0:00
    825-CL-A-41640-REG
    4.25
    7
    1/1/2014 0:00
    825-CL-A-41640-REG
    6.5
    8
    3/1/2014 0:00
    825-CL-E-41699-REG
    3
    9
    3/1/2014 0:00
    825-CL-E-41699-REG
    4


    This array formula** entered in E3:

    =SUM(IF(A2:A9=MAX(IF(LEFT(B2:B9,8)=E2,A2:A9)),C2:C9))

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  9. #9
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Calculate sum based on partial text match and latest date

    @Tony, I think that has the same problem I mentioned in post #4.

  10. #10
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: Calculate sum based on partial text match and latest date

    Quote Originally Posted by Tony Valko View Post
    =SUM(IF(A2:A9=MAX(IF(LEFT(B2:B9,8)=E2,A2:A9)),C2:C9))
    This formula will also give wrong output as pointed out by ragulduy in post#4.

  11. #11
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Calculate sum based on partial text match and latest date

    Quote Originally Posted by sktneer View Post
    This formula will also give wrong output as pointed out by ragulduy in post#4.
    I see.

    In that case try this array formula**:

    =SUM(IF(A2:A9=MAX(IF(LEFT(B2:B9,8)=E2,A2:A9)),IF(LEFT(B2:B9,8)=E2,C2:C9)))

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.

  12. #12
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: Calculate sum based on partial text match and latest date

    Try this....
    Please Login or Register  to view this content.

  13. #13
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Calculate sum based on partial text match and latest date

    Quote Originally Posted by moondog1023 View Post
    but also end with text string "REG" in column B.
    Ooops!

    I missed that part.

    Disregard all of my replies.

    I'll just move along!

  14. #14
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Calculate sum based on partial text match and latest date

    you can use wildcard in the search to reduce that a bit
    =SUMPRODUCT(--(ISNUMBER(SEARCH("825-CL-A*REG",B2:B20)))*(A2:A20=MAX(INDEX(ISNUMBER(SEARCH("825-CL-A",B2:B20))*A2:A20,0))),C2:C20)
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  15. #15
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Calculate sum based on partial text match and latest date

    Quote Originally Posted by martindwilson View Post
    you can use wildcard in the search to reduce that a bit
    =SUMPRODUCT(--(ISNUMBER(SEARCH("825-CL-A*REG",B2:B20)))*(A2:A20=MAX(INDEX(ISNUMBER(SEARCH("825-CL-A",B2:B20))*A2:A20,0))),C2:C20)
    I think you'd have to include the *REG in the MAX(Search as well.

  16. #16
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Calculate sum based on partial text match and latest date

    Or, maybe not!

  17. #17
    Registered User
    Join Date
    06-17-2014
    Location
    Guilford, CT
    MS-Off Ver
    2003
    Posts
    4

    Re: Calculate sum based on partial text match and latest date

    I tried ragulduy's second formula and again the resulting summed total is too high. I've attached an extract directly from my source data. The formula and result is in cell I1. I've highlighted the correct target rows which should sum to 29.33, not 157.49 as its currently doing.

    Example.xls

  18. #18
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Calculate sum based on partial text match and latest date

    Martin Wilson's formula in post #14 will do what you want.

    You just need to use the correct ranges.

  19. #19
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: Calculate sum based on partial text match and latest date

    Did you try the formula suggested in post#12 ? I think you didn't.
    Try this.....
    Please Login or Register  to view this content.
    See the attached sheet in which I have applied this formula in K1. Is it the desired output what you are expecting the formula to return?
    Attached Files Attached Files

  20. #20
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: Calculate sum based on partial text match and latest date

    Or alternatively you may try this also...
    Please Login or Register  to view this content.

  21. #21
    Registered User
    Join Date
    06-17-2014
    Location
    Guilford, CT
    MS-Off Ver
    2003
    Posts
    4

    Re: Calculate sum based on partial text match and latest date

    Several of these formulas worked in solving this problem, thanks again for all your help!

  22. #22
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Calculate sum based on partial text match and latest date

    Good deal. Thanks for the feedback!

    If your question has been solved please mark the thread as being solved.

    In the menu bar above the very first post select Thread Tools, then select Mark this thread as solved.

+ 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] Match partial text when partial text is not exact
    By NamiSama in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 05-21-2014, 07:18 PM
  2. Search and copy based on partial text match
    By PIQalap in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-12-2014, 11:36 AM
  3. Powerpivot - Returning latest update based on latest date
    By Kehjz in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 0
    Last Post: 08-22-2013, 02:45 PM
  4. Replies: 1
    Last Post: 01-20-2012, 09:44 AM
  5. remove duplicates based on partial text match
    By smelkin in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-16-2011, 09:45 AM

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