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.
[Solved] IF conditions
[Solved] IF conditions
Last edited by Hagar Delest on Thu May 07, 2020 7:10 am, edited 1 time in total.
Reason: tagged solved
Reason: tagged solved
OpenOffice 3.1 on Windows 7
Re: IF conditions
I think you want to use the SUMIF function. Something like
That would sum all of the column B values where the corresponding value in column A is equal to the A1 value.
Code: Select all
SUMIF($A$1:$A$10; A1; $B$1:$B$10)
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.
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Re: IF conditions
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)
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
Re: IF conditions
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.
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Re: IF conditions
That's exactly what i needed, thanks, and this code can work for any number of variables right?
OpenOffice 3.1 on Windows 7
Re: IF conditions
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
David
OS - Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.2.2.2; SlackBuild for 24.2.2 by Eric Hameleers