[Solved] SUMIF search criteria

Discuss the spreadsheet application
Post Reply
bobbert
Posts: 11
Joined: Wed Mar 28, 2012 4:02 pm
Location: Waterloo, Ontario

[Solved] SUMIF search criteria

Post by bobbert »

I'm trying to use the SUMIF function, but am unable to make it work the way i'd like. Instead of specifying the entire value for the search criteria, i'd like to be able to select records based on the first X number of characters in this field. For example, if the first 10 characters were always ACCOUNTING, but the rest of the field varied, is there a way to select records based only on the first 10 characters of the field? Hope i explained myself correctly.
Last edited by Hagar Delest on Fri Feb 16, 2018 10:40 pm, edited 1 time in total.
Reason: tagged [Solved].
Rob
FJCC
Moderator
Posts: 9283
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: SUMIF search criteria

Post by FJCC »

Try a formula like

Code: Select all

=SUMIF(D2:D7;"^accounting.*";E2:E7)
Be sure that regular expressions are enabled in the menu Tools -> Options -> OpenOffice Calc -> Calculate
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
User avatar
Lupp
Volunteer
Posts: 3553
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: SUMIF search criteria

Post by Lupp »

You may be even more flexible using SUMPRODUCT(). Assume column A is containing words and column B contains associated amounts.
If D2 now conatins a common keyword to find at the beginning of the words in column B for including the associated amount in the sum, you may use

Code: Select all

=SUMPRODUCT(B2:B101;LEFT(A2:A101;LEN(D2))=D2)
or similar.
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
bobbert
Posts: 11
Joined: Wed Mar 28, 2012 4:02 pm
Location: Waterloo, Ontario

Re: SUMIF search criteria

Post by bobbert »

FJCC this works exactly the way i wanted it to. Thank you, thank you, thank you.
Rob
Post Reply