Summing up rows in Excel if rows contain identical string - excel

I have a table with two columns. One column has names, the second column has numbers:
|-------|------|
| Names | Nums |
|-------|------|
| Name1 | 2 |
| Name5 | 3 |
| Name7 | 1 |
| Name1 | 1 |
| Some4 | 5 |
| Yay55 | 2 |
| Name1 | 1 |
| Name5 | 1 |
| Name5 | 7 |
| Name1 | 8 |
| Yay55 | 3 |
| Yay55 | 1 |
| Name1 | 0 |
|-------|------|
I am looking to consolidate this table to have unique Names only and a sum of all occurrences in the Nums column. Is it possible to achieve it without VB, and using only Excel functions?
Just to add a note, it should not be considered a duplicate question. I am aware of This Question, that is similar, but asks about VB.

You can use a Pivot Table to summarize your data by name and using the sum of values.
I.e.:
Creating the table:
Organizing data:

Related

Match first instance of cell in a column not equal to the other column with offset

Suppose I have the following table
+---+-------+-------+
| | A | B |
+---+-------+-------+
| 1 | 7,75 | 9,50 |
+---+-------+-------+
| 2 | 9,50 | 10,50 |
+---+-------+-------+
| 3 | 10,50 | 11,50 |
+---+-------+-------+
| 4 | 11,75 | 13,00 |
+---+-------+-------+
| 5 | 13,00 | 14,00 |
+---+-------+-------+
| 6 | 14,00 | 15,25 |
+---+-------+-------+
| 7 | 15,25 | |
+---+-------+-------+
I want to find the first occurrence in column A where it does not match column B with an offset of -1 in the rows (in this case, it should give me 11.75, A4)
I would like to avoid using VBA.
I tried using MATCH, but I'm unsure how to do the condition with 2 tables
Would this work for you:
=LOOKUP(1,1/(A2:A7<>B1:B6),A2:A7)
No need to CSE LOOKUP().
use INDEX/AGGREGATE:
=INDEX(A:A,AGGREGATE(15,7,ROW(A2:A7)/(A2:A7<>B1:B6),1))

Excel - avoiding indirect

I have the following three columns A,B,C
+-----------------+---------------+--------------------------------------------------------+
| ExcelRangedName | Default Value | Formula Check |
+-----------------+---------------+--------------------------------------------------------+
| Name1 | | =IF(AND(ISBLANK(B2),ISBLANK(INDIRECT(A2))),"Yes","No") |
| Name2 | FALSE | … |
| Name3 | TRUE | … |
| Name4 | 0 | … |
| Name5 | Alpha | … |
| Name6 | | … |
| Name7 | | … |
| Name8 | | … |
| … | … | … |
+-----------------+---------------+--------------------------------------------------------+
The column "ExcelRangedName" has text which refers to a range name in other worksheets. I want to replace the formula to remove the indirect completely as it is slowing down my worksheet. I remember being able to do this using paste values trick but I completely forgot how. I want my formula to look (for the first row):
=IF(AND(ISBLANK(B2),ISBLANK(Name1)),"Yes","No")
Is this possible?

Filter filter criteria and then apply in countif statement in Excel

I have a table of filter criteria like this:
+----------+----------+------+------+------+
| Category | SpecName | Spec | Pass | Fail |
+----------+----------+------+------+------+
| A | S1 | 3 | | |
| A | S2 | 4 | | |
| B | S1 | 5 | | |
| C | S1 | 2 | | |
+----------+----------+------+------+------+
I have a table I want to apply the filter criteria to like this:
+----------+----+----+
| Category | S1 | S2 |
+----------+----+----+
| A | 5 | 3 |
| B | 4 | |
| A | 5 | 5 |
| C | 2 | |
| A | 2 | 6 |
+----------+----+----+
I want to fill the Pass and Fail columns in the filter criteria table with a count of items in second table with values >= the corresponding spec, like so.
+----------+----------+------+------+------+
| Category | SpecName | Spec | Pass | Fail |
+----------+----------+------+------+------+
| A | S1 | 3 | 1 | 2 |
| A | S2 | 4 | 1 | 2 |
| B | S1 | 5 | 0 | 1 |
| C | S1 | 2 | 1 | 0 |
+----------+----------+------+------+------+
Here are steps for how I might do it in a scripting language:
Filter first table to get all spec filter criteria for the Category on that row, as follows for the first row.
+----------+----------+------+
| Category | SpecName | Spec |
+----------+----------+------+
| A | S1 | 3 |
| A | S2 | 4 |
+----------+----------+------+
Copy table 2 to a variable iTable
+----------+----+----+
| Category | S1 | S2 |
+----------+----+----+
| A | 5 | 3 |
| B | 4 | |
| A | 5 | 5 |
| C | 2 | |
| A | 2 | 6 |
+----------+----+----+
For each spec name:
Find column in iTable with spec name
Filter spec name column in iTable by spec
After all filters applied, we would have:
+----------+----+----+
| Category | S1 | S2 |
+----------+----+----+
| A | 5 | 5 |
+----------+----+----+
Then just count the rows in iTable and assign to the cell in Pass column of the criteria table
Is this possible with Excel formulas?
If not, does anyone know how to do it with VBA?
Looking at an alternative layout for you spec criteria. Expand you columns to suit your need.
With each spec criteria being its own column life gets really easy. You just need to adjust your formula to match the number of criteria you have.
Based on the table at the end for layout, place the following formula in D3 and copy down as required.
=SUMPRODUCT(($G$2:$G$6=A3)*($H$2:$H$6>=B3)*($I$2:$I$6>=C3))
That will give you a count of passing all criteria. Its also a function that performs array like calcs. It could be repeated in the next column but in order to reduce dependency on array calculation and potentially speed things up depending on the amount of data to check, place the following in the top of the fail column and copy down as required:
=COUNTIF($G$2:$G$6,A3)-D3
Basically it subtracts the passes from the total count. This assumes you can only have PASS and FAIL as options.

excel: filter using formulas

I have a list of people who belong to two groups (A or B). I want to create a column which lists all the people who belong to group A.
I have been trying to come up with an array formula but I do not have a working example. Any help appreciated!
Names | Group | Desired Output
Bob | A | Bob
Fred | B | Eric
Matt | B | Dave
Eric | A | Fred
Dave | A |
Stew | B |
Fred | A |
Many Thanks in advance
Normal formula for column C:
C2=
=IFERROR(INDEX(A:A,AGGREGATE(15,6,ROW(B:B)/(B:B="A"),ROW()-1)), "")
Copy/paste down in column C for a sufficient number of cells.
Array formula: select a sufficient number of cells in column C and write the same formula in the formula bar then press Ctrl+Shift+Enter
From this
+---+-------+-------+
| | A | B |
+---+-------+-------+
| 1 | Name | Group |
| 2 | Nick | A |
| 3 | Marc | A |
| 4 | Manny | B |
| 5 | Luck | A |
+---+-------+-------+
you can create two pivot tables with Name in the row label and Group in the filter data.
Then you can filter only people depending on the group.
+---+-------------------+---+
| | A | B |
+---+-------------------+---+
| 1 | Group | A |
| 2 | | |
| 3 | Etichette di riga | |
| 4 | Luck | |
| 5 | Marc | |
| 6 | Nick | |
+---+-------------------+---+
So if your data is in range A1:B7 this would be the formula:
=IFERROR(INDEX($A$1:$A$7,SMALL(IF($B$1:$B$7="A",ROW($A$1:$A$7)-ROW($A$1)+1),ROWS($A$1:A1))),"")
This is array formula that is applied with Ctrl + Shift + Enter and you will need to drag it down.

How to return columns with unique counts per value in other column

So I have a pandas dataframe containing names in 3 columns. Looking something like this:
+-------------+-------------+-------------+
| NameColumn1 | NameColumn2 | NameColumn3 |
+-------------+-------------+-------------+
| Name1 | Name2 | Name3 |
| Name1 | Name2 | Name6 |
| Name1 | Name2 | Name8 |
| Name1 | Name4 | Name5 |
+-------------+-------------+-------------+
Now I would like to add 3 new columns containing counts of the unique values per name in the column to the left of it.
So for example the first column I would like to add would be the count of unique names in Column2 per unique name in column 1. So that is 2 (Name2 and Name4) and add this to the dataframe.
For Column 3 and name in Column2 it would be 3 (name3, name6 and name8).
So for the example like this:
+----------+----------+----------+-------------+-------------+--+
| NameCol1 | NameCol2 | NameCol3 | CountOfCol2 | CountOfCol3 | |
+----------+----------+----------+-------------+-------------+--+
| Name1 | Name2 | Name3 | 2 | 3 | |
| Name1 | Name2 | Name6 | 2 | 3 | |
| Name1 | Name2 | Name8 | 2 | 3 | |
| Name1 | Name4 | Name5 | 2 | 1 | |
+----------+----------+----------+-------------+-------------+--+
This is how to get the answer for columns 2 and 3: count the unique pairs grouped by source against source,target pairs, broadcasting the result with the transform.
In [60]:df.groupby('NameColumn2')[['NameColumn2','NameColumn3']].transform(lambda x: x.nunique())['NameColumn3']
Out[60]:
0 3
1 3
2 3
3 1
Name: NameColumn3, dtype: int64
Replace 2 by x and 3 by y in the formula above to get result of countofColy for unique pairs of columnx, columny

Resources