Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

SUMIF row is equal to test value and row below is '-'

Hello,


I have a numbers spreadsheet where one column has a list of names that are mixed up with repeats, and another column that has a list of profit values relating to that name.


Now, I want to determine the total profit made from each of the names so I can see the total profit per name.


That part is easy, I just have a SUMIF function that checks if the name matches a specific name and then adds that profit to the total.


The problem I am having is that in the names column, sometimes I will have a name and then the next few rows are just '-' indicating that they are the same name. The SUMIF function I use does not take into account these values because they obviously don't match the name of interest.


So my question is: Is it possible to create a function that will check for a matching name, and then if the next row is '-', then add that value to the total as well. This has to work with multiple rows of '-' following a name.


The following screenshot is an example of what I mean since I realise that this may not make much sense.


User uploaded file

So in this case, Jess's total profit would be = 5 + 35 + 15 + 5 + 15 = 75

and Gill's profit = 30 + 30 + 20 + 40 = 120


I hope I've made this clear enough. Thank you in advance!


Oscar

Posted on Sep 2, 2016 5:54 AM

Reply
12 replies

Sep 2, 2016 7:00 AM in response to t quinn

Hi Oscar,


Here is a quick and dirty way to fix your list.

User uploaded file

You need an extra column for each - you want to eliminate. So to deal with billy's forth - I would need to add another column. If it was me, I would copy the final column and "paste formula results" into the original column and use the popup form then on.


quinn

Sep 2, 2016 6:59 AM in response to t quinn

Hi Quinn, thank you for your fast response.


I realise that it would be easier if all the "-" were replaced with the names, but the reason I have them like this is because the "-" indicates that the transaction was part of the same group, rather than being a completely separate event, which helps make it clearer when you are looking over the spreadsheet.


As for your "quick and dirty" method, I shall create a separate sheet that I can have all those extra columns in, and then it won't mess up the original.


If you (or anyone else) can think of a more convenient method for achieving the same result, then I'd be grateful to hear it.


Thanks for a quick solution though!

Sep 2, 2016 9:02 AM in response to Ozzmystro

Ozzmystro wrote:


the "-" indicates that the transaction was part of the same group, rather than being a completely separate event, which helps make it clearer when you are looking over the spreadsheet.




Instead of a - have you considered using Conditional Highlighting?


For example it is easy to achieve an effect like this:


User uploaded file


Select the cells in the column, click Conditional Highlighting in the pane at the right and Add a Rule:


User uploaded file



Click the "box with the arrow":


User uploaded file



Then click cell A1 (the cell immediately above the first of the selected cells).


User uploaded file


If you don't 'Preserve row' this highlighting rule will have each cell compare itself to the one immediately above it.


Then change the Bold to Custom Style (you have to scroll down in the list to see that):


User uploaded file


I chose a "grayer" text color when I defined the Custom Style. You could of course do something else to suit your taste, even make the contents "disappear."


By using Conditional Highlighting in this way you can avoid entering the - that complicate your formulas and table setup and simply use the SUMIF on the original column as you normally would.


SG

Sep 2, 2016 9:02 AM in response to SGIII

Hi SG, thanks for your reply.


I do actually use conditional highlighting throughout my spreadsheet which is extremely useful.


However, the technique you suggest wouldn't work in all cases. This is because if I had, say, 4 transactions from "jess" that were all part of the same group, and then following that I had another transaction from "Jess" that wasn't part of that group, then your technique would grey out that transaction even though it's not part of the group.


You are right though, something along those lines would be the best way of achieving the desired outcome and allow me to easily use the SUMIF function.


Can you think of a way that would allow me to achieve this?


Thanks everyone for your input so far!

Sep 2, 2016 9:08 AM in response to Ozzmystro

What immediately comes to mind is that groups seem to be important to your analysis. If that is the case, then you may find it helpful to add a Group column and assign each transaction to a group. Then in pulling summary statistics you can use the Group column with SUMIF. Or use SUMIFS referencing both the Name and Group columns. As you probably know, SUMIF works with one column-condition pair. SUMIFS can have multiple column-condition pairs.


SG

Sep 5, 2016 5:56 AM in response to Ozzmystro

Hi,


In the end, I used Quinn's method to replace the original column with the names, and then instead of creating a group column (which is a good idea but doesn't necessarily apply to my spreadsheet), I have coloured the names so that they blend in with the background colour, ie. they aren't visible.


I couldn't work out a way to use conditional formatting to colour the names so I've resorted to doing this manually.


Is there a way of using conditional formatting that references the column next to it? ie. using an IF statement? It doesn't look like this is possible. The reason I ask is because the second column either has a number or "-" and I want the colour of the name to be grey if the column next to it is "-".


Not sure if we're going round in circles here. Thanks for all your help anyway guys!

SUMIF row is equal to test value and row below is '-'

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.