Hi Laura,
If your document lists transactions during a single year, you'll be able to get the totals you want using SUMIF.
If the document contains transactions during a period of more than a year, you'll need to turn to SUMIFS.
Here's are two small examples illustrating each case.
In the simpler case above, where all transactions are in the same year, the formula is concerned only with totals for each category.
The Expenses-1 table has no formulas. All data shown is entered directly.
Summary-1 has two formulas:
Summary-1::C2: IF(LEN(A2)<1,"",SUMIF('Expenses-1'::B,A2,'Expenses-1'::C))
Filled down to C10.
The part shown in bold checks the categories in column B of the Expenses-1 table for a match with the category name in cell A2 ('this row') of 'this table', and, where it finds a match, includes the amount in that row of column C of Expenses-1.
The part in normal type is a 'switch' that prevents the SUMIF part from being called when the category cell in column A is empty.
C11: SUM(C)
Calculates the total expenses for all listed categories. Used here as a checksum to show the number of expenses included in the total above. As all expenses listed are 1.00, the number should equal the number of rows included in the total.
The second case contains expenses from two years, 2017 and 2018. The Summarised totals are to consider only the expenses recorded with dates in 2018:
Data here is the same set as above, except that the dates cover a different period—15 are in December, 2017, and are not to be included in the totals, 14 are in January and February of 2018, and are to be included.
As above, Expenses has no formulas. All data is idrectly entered.
Summary has an added Header row to contain the year to which the Summary applies.
As in the first example, Summary has two formulas:
C12: SUM(C)
This is the same formula as in the summary table in the first example, pushed down one row by the added header row in this example.
C3: IF(LEN(A3)<1,"",SUMIFS(Expenses::C,Expenses::A,">="&DATE(A$1,1,1),Expenses::A,"<"&DATE(A$1+1,1,1 ),Expenses::B,A3))
Fill down to C11.
The normal type part is the same as in the first example.
The bold part uses SUMIFS in place of SUMIF as it now has to consider the date in column A as well as the category in column B.
SUMIFS also reverses the order of arguments, placing the sum-values first, followed by as many pairs of test-values,condition as needed (in this case, 3). ALL test-value, condition pairs must return 'true' for the sum-value on that row to be included in the sum.
test-value,condition:
Expenses::A,">="&DATE(A$1,1,1), the date in column A of Expenses must be on or after
January 1 of the year in A1 of 'this table' (Summary)
Expenses::A,"<"&DATE(A$1+1,1,1), the date in column A of Expenses must be before
January 1 of the year after the year in A1 of 'this table' (Summary)
Expenses::B,A3 the category in column B must match the category in
'this row' of column A of 'this table'.
If all three conditions are met, the value is included in the sum in the cell containing the formula.
Regards,
Barry