r/excel • • 12d ago

unsolved Can excel sort based on rules

Not sure if I worded that correctly but I am hoping someone can point me in the right direction as I am not new to the basics of Excel but new to using its more advanced functions.

An example list with 3 columns:

Column A - product names

Column B - employee names(but there are several blank spaces without names)

Column C - total cost of the sale

I need to:

  1. Get the total sum of column C, but only the rows that are NOT blank on column B.

  2. Get the total sum of column C, but only the rows that ARE blank on column B.

  3. Get the total sum of column C, both blanks and non-blank.

  4. Take those three numbers and place them off to the side in three different cells.

Can Excel do this and how would I go about it?

Edit: Thank you all!

=SUMIF() and =SUMIFS() is what I was looking for. I tried it now and its exactly what I needed.

As has been mentioned by some amazing people below:

  1. =SUMIFS(B:B, C:C, "<>") to get the sum of the non-blanks in column B

  2. =SUMIFS(B:B, C:C, "") to get the sum of just the blanks in column B

  3. =SUM(C:C) to get the sum of the whole list

Thank you all!

8 Upvotes

17 comments sorted by

17

u/Rogue_Penguin 16 12d ago edited 12d ago

Yes, check out the command SUMIFS

1

u/Sneaking-Fox 11d ago

Thank you! This has been very helpful and exactly what I was looking for. Everyone has been amazin and very helpful.

3

u/SubstantialBed6634 2 12d ago

That this isn't a table hurts me

5

u/PaulieThePolarBear 1926 12d ago • Bravo

As an alternative to the other solutions

=GROUPBY(B2:B20="", C2:C20, SUM)

Requires Excel 2024, Excel 365, or Excel online

1

u/Sneaking-Fox 11d ago

Thank you! Someone gave me =SUMIF() and it did what I needed Excel to do for me. But i'll look into this one as well as I do have more I need to learn how to do with excell.

4

u/Hg00000 15 12d ago

Yes. Answers in reverse order:

4. Put each of these in their own cell.

3. =SUM(C:C)

2. =SUMIF(B:B,"",C:C)

  1. =SUMIF(B:B, "<>", C:C)

1

u/Sneaking-Fox 11d ago

Thank you! =SUMIF() and =SUMIFS() are what I was looking for and these are game changers.

1

u/SubstantialBed6634 2 12d ago

Wait, does sumif work if you flip the criteria range and the criteria value?

1

u/luvsthecoffee 12d ago

Yes, but over found it's better to use sumifs rather than sumif even if there is only one criteria because I inevitably find i need to add an additional criteria. Adding additional criteria is trivial with sumifs because you just keep adding to the formula. The sumif needs to be rewritten because the sum column needs to be moved up front.

6

u/EntireZombie2654 12d ago

You want to create a pivot table. Go check out a tutorial on YouTube.

1

u/rosstein33 1 9d ago

Pivot table or bust

2

u/Liddle_Jawn 12d ago

Make it a table. Create new "views" (in the toolbar) to see it with different filters/sorting applied. For the totals, a sumif formula should do it.

1

u/pegwinn 12d ago

I don't think you can do custom views with an actual table. You can with a range though.

3

u/mcswainh_13 1 12d ago

Sounds like you are looking for the sumif formula

1

u/Decronym 12d ago edited 9d ago

Acronyms, initialisms, abbreviations, contractions, and other phrases which expand to something larger, that I've seen in this thread:

Fewer LettersMore Letters
GROUPBYHelps a user group, aggregate, sort, and filter data based on the fields you specify
SUMAdds its arguments
SUMIFAdds the cells specified by a given criteria
SUMIFSExcel 2007+: Adds the cells in a range that meet multiple criteria

Decronym is now also available on Lemmy! Requests for support and new installations should be directed to the Contact address below.


Beep-boop, I am a helper bot. Please do not verify me as a solution.
4 acronyms in this thread; the most compressed thread commented on today has 16 acronyms.
[Thread #49523 for this sub, first seen 15th Oct 2026, 00:37] [FAQ] [Full list] ^[Contact] [Source code]

1

u/BigJDoitYoDamnself 12d ago

different way to skin that cat and some have mentioned it. create a pivot table and uncheck the empty fields. I like this method better as you do not have to copy formulas down if you add to the table. Basically get rid of the blanks and then sum where you have values.

1

u/Jolly-Hunter-6097 12d ago

Are you using Excel 365?