How do I calculate a column based on two criteria?

charlesstricklin

Board Regular
Joined
May 6, 2013
Messages
98
Office Version
  1. 2021
Platform
  1. Windows
I have been fiddling with this for an hour, mostly using SUMIFS but I'm not getting anywhere. Assume I present the following data:

A`BC
1​
$ 81.00ExpensePersonal
2​
$ 75.00ExpensePersonal
3​
$ 25.00ExpensePersonal
4​
$ 42.00ExpenseBusiness
5​
$ 14.00ExpensePersonal
6​
$ 59.00IncomePersonal
7​
$ 71.00ExpenseBusiness
8​
$ 70.00ExpenseBusiness
9​
$ 91.00ExpensePersonal
10​
$ 88.00IncomeBusiness
11​
$ 48.00IncomeBusiness
12​
$ 4.00ExpensePersonal
13​
$ 82.00ExpenseBusiness
14​
$ 58.00ExpenseBusiness
15​
$ 49.00ExpensePersonal
16​
$ 71.00Expense
Personal​
17​
$ 8.00ExpensePersonal
18​
$ 88.00IncomePersonal
19​
$ 3.00ExpensePersonal
20​
$ 78.00IncomePersonal

How do I calculate Business Income, Business Expenses, Personal Profit/Loss, Total Income, etc.?
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
how about
=SUMIFS(A1:A20,B1:B20,D2,C1:C20,E2)
where D2 and E2 are the criteria

how do you define Profit/loss???
total income - is that Business income
if so its in example below

Book1
ABCDEF
181ExpensePersonal
275ExpensePersonalExpensePersonal350
325ExpensePersonalIncomePersonal225
442ExpenseBusinessExpenseBusiness323
514ExpensePersonalIncomeBusiness136
659IncomePersonal0
771ExpenseBusiness0
870ExpenseBusiness0
991ExpensePersonal
1088IncomeBusiness
1148IncomeBusiness
124ExpensePersonal
1382ExpenseBusiness
1458ExpenseBusiness
1549ExpensePersonal
1671ExpensePersonal
178ExpensePersonal
1888IncomePersonal
193ExpensePersonal
2078IncomePersonal
Sheet1
Cell Formulas
RangeFormula
F2:F8F2=SUMIFS(A1:A20,B1:B20,D2,C1:C20,E2)
 
Upvote 0
Should be a pretty straightforward SUMIFS formula.

For Business Income the formula would be:
Excel Formula:
=SUMIFS(A1:A20,B1:B20,"Income",C1:C20,"Business")
and repeat the same logic for the other ones.
 
Upvote 1
This could be done with SUMIFS but I would use a pivot table.

$scratch.xlsm
ABCDEFG
1 Amount TypePersonal/BusinessSum of AmountColumn Labels
2 $ 81.00 ExpensePersonalRow LabelsBusinessPersonal
3 $ 75.00 ExpensePersonalExpense323421
4 $ 25.00 ExpensePersonalIncome136225
5 $ 42.00 ExpenseBusiness
6 $ 14.00 ExpensePersonal
7 $ 59.00 IncomePersonal
8 $ 71.00 ExpenseBusiness
9 $ 70.00 ExpenseBusiness
10 $ 91.00 ExpensePersonal
11 $ 88.00 IncomeBusiness
12 $ 48.00 IncomeBusiness
13 $ 4.00 ExpensePersonal
14 $ 82.00 ExpenseBusiness
15 $ 58.00 ExpenseBusiness
16 $ 49.00 ExpensePersonal
17 $ 71.00 ExpensePersonal
18 $ 8.00 ExpensePersonal
19 $ 88.00 IncomePersonal
20 $ 3.00 ExpensePersonal
21 $ 78.00 IncomePersonal
Sheet15
 
Upvote 0
A Power Query Solution

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", Currency.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Column2", "Column3"}, {{"Total", each List.Sum([Column1]), type nullable number}})
in
    #"Grouped Rows"

Book4
ABCDEFG
1Column1Column2Column3Column2Column3Total
2$81.00ExpensePersonalExpensePersonal350
3$75.00ExpensePersonalExpenseBusiness323
4$25.00ExpensePersonalIncomePersonal225
5$42.00ExpenseBusinessIncomeBusiness136
6$14.00ExpensePersonalExpensePersonal71
7$59.00IncomePersonal
8$71.00ExpenseBusiness
9$70.00ExpenseBusiness
10$91.00ExpensePersonal
11$88.00IncomeBusiness
12$48.00IncomeBusiness
13$4.00ExpensePersonal
14$82.00ExpenseBusiness
15$58.00ExpenseBusiness
16$49.00ExpensePersonal
17$71.00ExpensePersonal
18$8.00ExpensePersonal
19$88.00IncomePersonal
20$3.00ExpensePersonal
21$78.00IncomePersonal
Sheet1
 
Upvote 0
I know the OP is still on 2010, but for anyone else that is using O365, here is the new GroupBy formula

=GROUPBY(Table1[[Column2]:[Column3]],Table1[Column1],SUM)

and the result looks as follows:

ExpenseBusiness323
ExpensePersonal350
ExpensePersonal71
IncomeBusiness136
IncomePersonal225
Total1105
 
Upvote 0
You seem to have some kind of stray character on row 16. Delete the cell with "Personal" and type it in again. Maybe that is messing with your formulas.
 
Upvote 0
I know the OP is still on 2010, but for anyone else that is using O365, here is the new GroupBy formula

=GROUPBY(Table1[[Column2]:[Column3]],Table1[Column1],SUM)
GROUPBY is not available on all versions of 365. I think it's only available to Insiders at the moment. (Also true for PIVOTBY)
 
Upvote 0
thanks Jeff. Not sure what it was, but the codes remain the same and the data updates to the correct amounts
 
Upvote 0
Should be a pretty straightforward SUMIFS formula.

For Business Income the formula would be:
Excel Formula:
=SUMIFS(A1:A20,B1:B20,"Income",C1:C20,"Business")
and repeat the same logic for the other ones.
Thanks!
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,186
Members
452,615
Latest member
bogeys2birdies

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top