Help with the Sum function

Dan Wilson

Well-known Member
Joined
Feb 5, 2006
Messages
550
Office Version
  1. 365
Platform
  1. Windows
Good day. I have spent the last hour trying to make this work, but I no luck. I have a worksheet that contains a list of "Services", "Installations" and "Repairs" to my motorcycle. For instance, "3/1/2024" is in Columns A. "Replaced Battery" is in Column B, "135.00" is in Column C and "R" is in Column D. I am trying to total the costs that match "S", "I", or "R" in Column D. There are currently 32 items in the list, but I don't think that has anything to do with the problem. I have tried SUMIF and SUMIFS, with no luck. For some reason, my brain is not working. I appreciate any help with this one.
Thanks, Dan...
 
suppose column D contains text like "S...", or "I...", or "R...", column C contains value need to be summed
with maximum rows is 100
There are several ways, try:
=SUMIF($D$1:$D$100,"S*",$C$1:$C$100) + SUMIF($D$1:$D$100,"I*",$C$1:$C$100) + SUMIF($D$1:$D$100,"R*",$C$1:$C$100)
or
=SUMPRODUCT(( (LEFT($D$1:$D$100)="S") + (LEFT($D$1:$D$100)="I") + (LEFT($D$1:$D$100)="R") )*$C$1:$C$100)
 
Upvote 0
Solution
Good day bebo021999 and THANK YOU for responding. I used the SUMIF formula and found that the "$" is absolutely necessary to make it work. This forum is a life-saver and very educational. I will experiment with the SUMPRODUCT function as I have never used it.
Thank you, Dan...
 
Upvote 0
Do you have the GROUPBY function? If so, is this what you want?

25 03 31.xlsm
BCDEFG
1DescriptionAmountTypeTypeAmount
2Replaced Battery135.00RepairInstallation423.00
3Schedule Service200.00ServiceRepair381.00
4Fixed tail light45.00RepairService355.00
5Installed something423.00InstallationTotal1,159.00
6Replaced Windshield201.00Repair
7Extra Service155.00Service
8
Motorcycle
Cell Formulas
RangeFormula
F2:G5F2=GROUPBY(D2:D7,C2:C7,SUM)
Dynamic array formulas.


Otherwise, what about using Excel's built-in Pivot Table feature (on the 'Insert; ribbon tab)?

25 03 31.xlsm
BCDEFG
1DescriptionAmountTypeRow LabelsSum of Amount
2Replaced Battery135.00RepairRepair381.00
3Schedule Service200.00ServiceService355.00
4Fixed tail light45.00RepairInstallation423.00
5Installed something423.00InstallationGrand Total1,159.00
6Replaced Windshield201.00Repair
7Extra Service155.00Service
8
Motorcycle (2)


.. or is it something else you want?
 
Upvote 0
Good day bebo021999 and THANK YOU for responding. I used the SUMIF formula and found that the "$" is absolutely necessary to make it work. This forum is a life-saver and very educational. I will experiment with the SUMPRODUCT function as I have never used it.
Thank you, Dan...
@Dan Wilson, since you've indicated that you wanted to look into sumproduct there is a small error in the sumproduct formula that, while it will work correctly (in this case), may confuse you.
Sumproduct should have multiple ranges separated by commas, so this should be:
Excel Formula:
=SUMPRODUCT(( (LEFT($D$1:$D$100)="S") + (LEFT($D$1:$D$100)="I") + (LEFT($D$1:$D$100)="R") ),$C$1:$C$100)
or use the sum formula instead:
Excel Formula:
=SUM(( (LEFT($D$1:$D$100)="S") + (LEFT($D$1:$D$100)="I") + (LEFT($D$1:$D$100)="R") )*$C$1:$C$100)
Personally I'd use a pivot table to summarise this data as PeterSSs has suggested as it gives the information about the sub-groups and the whole together if (when, from my experience :)) you need it in future.
 
Upvote 0
Do you have the GROUPBY function? If so, is this what you want?

25 03 31.xlsm
BCDEFG
1DescriptionAmountTypeTypeAmount
2Replaced Battery135.00RI423.00
3Schedule Service200.00SR381.00
4Fixed tail light45.00RS355.00
5Installed something423.00ITotal1,159.00
6Replaced Windshield201.00R
7Extra Service155.00S
8
Motorcycle
Cell Formulas
RangeFormula
F2:G5F2=GROUPBY(D2:D7,C2:C7,SUM)
Dynamic array formulas.


Otherwise, what about using Excel's built-in Pivot Table feature (on the 'Insert; ribbon tab)?

25 03 31.xlsm
BCDEFG
1DescriptionAmountTypeRow LabelsSum of Amount
2Replaced Battery135.00RI423.00
3Schedule Service200.00SR381.00
4Fixed tail light45.00RS355.00
5Installed something423.00IGrand Total1,159.00
6Replaced Windshield201.00R
7Extra Service155.00S
8
Motorcycle (2)


.. or is it something else you want?
Good day Peter_SSs and thank you for responding. The issue has been resolved, but I ill investigate your response. I don't know if I have the GROUPBY function, but it looks interesting.
Thank, Dan...
 
Upvote 0
@Dan Wilson, since you've indicated that you wanted to look into sumproduct there is a small error in the sumproduct formula that, while it will work correctly (in this case), may confuse you.
Sumproduct should have multiple ranges separated by commas, so this should be:
Excel Formula:
=SUMPRODUCT(( (LEFT($D$1:$D$100)="S") + (LEFT($D$1:$D$100)="I") + (LEFT($D$1:$D$100)="R") ),$C$1:$C$100)
or use the sum formula instead:
Excel Formula:
=SUM(( (LEFT($D$1:$D$100)="S") + (LEFT($D$1:$D$100)="I") + (LEFT($D$1:$D$100)="R") )*$C$1:$C$100)
Personally I'd use a pivot table to summarise this data as PeterSSs has suggested as it gives the information about the sub-groups and the whole together if (when, from my experience :)) you need it in future.
Good day Teeroy and thanks for responding. The issue has been resolved and thank you for the update on the SUMPRODUCT function. I appreciate the update.
Thanks, Dan...
 
Upvote 0

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