[Solved] IF conditions

Discuss the spreadsheet application
Post Reply
DuarteSC
Posts: 4
Joined: Thu May 07, 2020 12:34 am

[Solved] IF conditions

Post by DuarteSC »

Hey,
Sorry if this is a basic question, but I've been using calc for a few years and I always been able to find the answers, but I don't really know how to search this.
So, I want to use a IF condition like this:

If the value of the column A is 'x' then i want the correspondent value of B to be added.

Example:

Column A:
A1.Dog
A2.Cat
A3.Dog
A4.Cat
A5.Cat
(...)

Column B:
B1.1
B2.2
B3.1
B4.1
B5.0
(...)

So, IF in A you have "Dog" then i want the sum of the Column B value.
In this case would be B1 + B3 the answer.

Not sure if i explained myself properly, but if you guys can help me, that would be great.
Last edited by Hagar Delest on Thu May 07, 2020 7:10 am, edited 1 time in total.
Reason: tagged solved
OpenOffice 3.1 on Windows 7
FJCC
Moderator
Posts: 9280
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: IF conditions

Post by FJCC »

I think you want to use the SUMIF function. Something like

Code: Select all

SUMIF($A$1:$A$10; A1; $B$1:$B$10)
That would sum all of the column B values where the corresponding value in column A is equal to the A1 value.
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.
DuarteSC
Posts: 4
Joined: Thu May 07, 2020 12:34 am

Re: IF conditions

Post by DuarteSC »

Yet, that's it. Thanks.
Just another question, is it possible to had 2nd condition in order to get the Sum of the values of B?
In this case assuming it had to be a Dog and Grey for example (this value would come from Column C)
OpenOffice 3.1 on Windows 7
FJCC
Moderator
Posts: 9280
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: IF conditions

Post by FJCC »

There is a SUMIFS function but I prefer the more flexible SUMPRODUCT function.

Code: Select all

=SUMPRODUCT(A1:A8 = "Dog"; B1:B8 = "Grey"; C1:C8)
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.
DuarteSC
Posts: 4
Joined: Thu May 07, 2020 12:34 am

Re: IF conditions

Post by DuarteSC »

That's exactly what i needed, thanks, and this code can work for any number of variables right?
OpenOffice 3.1 on Windows 7
User avatar
robleyd
Moderator
Posts: 5087
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: IF conditions

Post by robleyd »

SUMPRODUCT has a maximum of 30 arguments. See the HELP - F1 - and you might also find [Tutorial] The SUMPRODUCT function a useful resource.
Cheers
David
OS - Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.2.2.2; SlackBuild for 24.2.2 by Eric Hameleers
DuarteSC
Posts: 4
Joined: Thu May 07, 2020 12:34 am

Re: IF conditions

Post by DuarteSC »

Thanks, you can close the topic.
OpenOffice 3.1 on Windows 7
Post Reply