Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add numbers only if some other cell matches a particular criteria in Google Spreadsheets?

situation

A spreadsheet to maintain accounts.

A form as so: The form

What I want to do

I want to add the value in the column D if it has Type of transaction = Credit and If it has type of transaction = debit then I want to subtract it from the total. I am finding this total inside the spreadsheet itself. So I think SUMIF(...,...,...) will be used but I am not sure.

Spreadsheet for reference.

I guess:

The criteria could be what is the first letter of the cell in column C which is in the same row as the cell now being considered which belongs to column D. If it is of the form C* then it is credit if it is of the form D* then it is a debit transaction. But I am unable to find out how to apply this condition.

like image 818
IcyFlame Avatar asked Jul 23 '13 14:07

IcyFlame


People also ask

How do you add cells only if another cell meets criteria?

For example, the formula =SUMIF(B2:B5, "John", C2:C5) sums only the values in the range C2:C5, where the corresponding cells in the range B2:B5 equal "John." To sum cells based on multiple criteria, see SUMIFS function.

How do I sum values based on criteria in another column in Google Sheets?

Google Sheets SUMIF to sum a data range on a condition SUMIF is a Google Sheets function to return a total of cells that match a single specific criterion. Put simply, the SUMIF function filters the range according to the specified criteria and sums values based on this filter. The syntax is the same as SUMIF Excel.

How do you write an IF THEN formula in Google Sheets?

Using the IF Function The IF function can be used on its own in a single logical test, or you can nest multiple IF statements into a single formula for more complex tests. To start, open your Google Sheets spreadsheet and then type =IF(test, value_if_true, value_if_false) into a cell.


1 Answers

The SUMIF criteria in Spreadsheet works as follows:

=SUMIF(range, criteria, sum_range)

whereby range is the range from which you want to match (C column in your example, which has Debit/Credit)

Criteria = what should match (Debit or Credit based on the formula in your example)

Sum_range = The Column that needs to be summed - (D column in your example)

So your formula should be somewhat

=SUMIF(C1:C1000,"D"&"*",D1:D1000) for Debit
=SUMIF(C1:C1000,"C"&"*",D1:D1000) for Credit

Note: you can use "Debit" or "Credit" in place of "D"&"" or "C"&"" respectively.

like image 116
Vasim Avatar answered Sep 30 '22 01:09

Vasim