2

Using LibreOffice Calc with the expression SUMIF, is there a way to make the criteria field look for 2 types of values using OR logic? Or do I have to make 2 separate SUMIF's and just add them up?

A    B  
Joe  1  
Joe  2  
Tim  3  
Roy  4  
Tim  5  
Roy  6  

How do I make a SUMIF to the rows for Joe and Roy so the result is 13? Basically I want it to sum IF cells in A are Joe OR Roy.

Thanks

tohuwawohu
  • 10,303
  • 1
  • 35
  • 63
timoseewho
  • 645
  • 3
  • 10
  • 17
  • It might help if you gave an example of your data and what you want to compute.  Please do not respond in comments; [edit] your question to make it clearer.  Create a *small* data set that illustrates your problem (see [this](http://stackoverflow.com/help/mcve)).  It doesn’t have to be your *real* data; it’s preferable to use dummy/test data.  Don’t use 10-digit numbers if you can make do with 2-digit numbers.  Don’t post screenshots — just type in a textual representation of your data, as was done [here](http://superuser.com/q/889201/150988) and [here](http://superuser.com/q/892744/150988). – Scott - Слава Україні Apr 10 '16 at 05:10

1 Answers1

2

You may use the pipe character | for alternative matches:

=SUMIF(A1:A6;"=Joe|Roy";B1:B6)

Take care to adapt the semicola ; depending on your localisation, and make sure that regular expressions are enabled in the settings (Tools -> Options -> LibreOffice Calc -> Calculate).

tohuwawohu
  • 10,303
  • 1
  • 35
  • 63
  • thank you very very much! why is the ; necessary this time around though? – timoseewho Apr 10 '16 at 14:15
  • LO uses different characters to separate parts of formulas, depending on your localisation. In my case, it's a semicolon `;`, but if you're using a different localisation, this may break the formula. So, if LO doesn't accept an example formula, it's usually due to different localisation settings. – tohuwawohu Apr 10 '16 at 14:20
  • would you happen to know how to do this exact same thing, but on Google Sheets? or would you rather me open another question? i'm unfamiliar with the etiquette here> – timoseewho Apr 19 '16 at 05:29
  • I'm sorry, but i havent' worked with Google Sheets yet, so i can't tell about. Anyway, it's better to open a new question, but first you should check if there's some documentation about support for functions in Google Sheet. – tohuwawohu Apr 19 '16 at 06:10