Excel removing all rows where the first, last, and email are all the same - excel

I'm struggling over how to remove certain rows in my excel sheet. Right now I have something like this:
https://i.stack.imgur.com/c5Pxi.png
First Last Email Amount
A B AB#gmail.com $25
A B AB#gmail.com $25
A B AB#gmail.com $25
A B AB#gmail.com $25
Z Y AB#gmail.com $10
1 2 12#gmail.com $50.00
1 2 12#gmail.com $50.00
3 4 12#gmail.com $50.00
Qwerty Uiop Qwerty#gmail.com 50
Qwerty Uiop Qwerty#gmail.com 50
Qwerty Uiop Qwerty#gmail.com 50
Qwerty Uiop Qwerty#gmail.com 50
I want to know how i can analyze this data and delete all people who have only entered the same first and last name and email for all of their transactions. For example, in this image, Qwerty#gmail.com has 4 transactions, but they all have the same first and last name, so i want to delete all rows containing qwerty#gmail.com. However, AB#gmail.com has 4 transactions with the name A B and 1 transaction with the name Z Y, so i don't want to remove any rows containing AB#gmail.com.
Can anyone help suggest a way this could be done?

Excel has a built-in facility for removing Duplicate values.
Select the range of cells containing the data
On the Data tab click Remove Duplicates
Under Columns, select the columns you wish to include in the check for duplicates
Click OK
After the message saying how many records will be removed, Click OK

You can use the Advanced Filter with a formula criteria.
The formula:
A2: =COUNTIFS(Sheet3!$C$8:$C$19,C8,Sheet3!$A$8:$A$19,A8,Sheet3!$B$8:$B$19,B8)/COUNTIF(Sheet3!$C$8:$C$19,C8)<>1
Before
Filter Dialog
After

Related

How to condense column data in excel at a change in the row data

I'm not sure exactly how to explain this, but I want to combine rows in Excel while condensing the column data. I'm looking to take a spreadsheet like this:
Name
Coffee
Bananas
Chocolate Ice Cream
Tom
4
Tom
2
Tom
2
Jerry
1
Jerry
4
Amanda
3
Amanda
2
and turn it into this:
Name
Coffee
Bananas
Chocolate Ice Cream
Tom
4
2
2
Jerry
1
4
Amanda
3
2
Any tips would be super helpful.
You can setup a pivot table for this.
Select your table > Insert Pivot Table, then follow this screenshot:
Drag Name colum in Rows
Drag Coffee, Bananas, Chocolate ice creams in Values and you're set!
If you want the data transformed and cleansed, you can always use PowerQuery.
Go to Data -> Get Data -> From File -> whatever source your data is in.
In there, use the Group By function to suppress the rows.
From there, you'll have a new set of data which can then be loaded into the destination worksheet.
If the usage of PowerQuery is new to you, a quick Google search will help you through this.
Naturally, this assumes you have a version of Excel that has PQ built in.
Here/screenshot(s) refer:
Condensed table comprises 3 sections (colour coded respectively):
Row labels (names, blue) - assuming these are unique at source
Column labels (food product, green) - ditto
Values (sum per row / col label, yellow)
note: included an extra '1' for Tom + Chocolate IC in 1st row for testing...
1] Row labels
=UNIQUE(D7:D13)
(array function - requires Office 365 compatible version of Excel)
2] Col labels
=E6:G6
(array function - enter in single cell if using Office 365 compatible version of Excel, otherwise highlight relevant area and enter function with shift + alt + enter)
3] Values
=SUMIFS(INDEX($E$7:$G$13,0,MATCH(J$6,$E$6:$G$6,0)),$D$7:$D$13,$I7)
(can drag this function across values / yellow section)

how to count distinct values in excel for a matrix form

I have looked if this has been asked, but could not find out exactly.
I' ve been trying to count distinct values.
I tried sumproduct,sum(1/countif) etc, so far I got nothing but a div error or 0.
Basically, I' ve two columns: Campaign_no and customer_id.
what I need is count unique customers for each campaigns and count unique customers that appears in the campaigns at the same time, sort of matrix.
The table is as follows:
Campaign_no
Cust_id
A
1
A
2
A
2
B
1
B
4
B
5
B
9
C
4
C
5
C
6
C
7
What I need is below:
Campaigns
A
B
C
A
2
1
0
B
1
4
2
C
0
2
4
As you see Campaign A has 2 unique customers, so A-A cell is 2.
Campaign A and B have one customer in common, so A-B cell is 1.
Campaign A and C have no common customer, this box got 0.
Campaign B and C has 4 unique customer on their own,
but they have two common customers, so B-C box has 2 ( if those customers were the same, it would have been 1) .
Is there way of calculating this without vba or PT? I'm using Excel 2017.
Much appreciated.
Here is a solution using helper cells.
C2 is =A2&B2. Copy it to C3:C12.
D2 is =IF(ISNA(MATCH(B2,D1:$D$1,0)),B2,""). Copy it to D3:D12.
E2 is =IF($D2="","",1-ISNA(MATCH(E$1&$D2,$C$2:$C$12,0))). Copy it to E2:G12.
E15 is =SUMIFS($E$2:$E$12,E2:E12,1). Copy it to F15:G15.
E16 is =SUMIFS($F$2:$F$12,E2:E12,1). Copy it to F16:G16.
E17 is =SUMIFS($G$2:$G$12,E2:E12,1). Copy it to F17:G17.
You may be able to get away without using the helper column C in Office 2017. I only have Office 365, so I couldn't it correctly.
Here's one that you could try, but it assumes that the data is sorted into contiguous blocks in alphabetical order of campaign exactly as shown in the sample data:
=SUMPRODUCT((COUNTIFS($A$2:$A$12,F$1,$B$2:$B$12,INDEX($B$2:$B$12,MATCH($E2,$A$2:$A$12,0)):INDEX($B$2:$B$12,MATCH($E2,$A$2:$A$12,1)))>0)
/COUNTIFS($A$2:$A$12,$E2,$B$2:$B$12,INDEX($B$2:$B$12,MATCH($E2,$A$2:$A$12,0)):INDEX($B$2:$B$12,MATCH($E2,$A$2:$A$12,1))))
The idea is that you use countifs to check through each customer ID in campaign A (for example) to see if it's present in campaign B. But it's possible that a customer ID appears more than once in campaign A, so you still have to divide by the count of each customer number in campaign A to get the unique count.

Aggregating records with two main IDs in [VBA macro]

I want to make a macro in Excel that summarizes data from rows that match a composite ID generated from 2 ID columns. In my excel sheet, each row has 2 main ID columns: ID_1 is the main key, and ID_2 is a secondary key from which I only care about the first 2 letters (Which I have gotten using LEFT). I want to group rows with the same ID_1 and first 2 letters of ID_2 and report the SUM of the value, count, and sum columns.
In the example picture below, I want to turn the data in columns A:J into the data in columns M:V
So, with this example -> We have 6 records 1015 (ID_1) with 3 different ID_2 (AB, AZ, AE). I want to sum them up to a one cell each (1015 AB ; 1015 AZ ;1015 AE) with values which each record had (there is 3 records: 1015 AB with VALUE of 2,3,4 so in result I want to get just one row 1015 AB 9(sum of value) 4(sum of count) 17 (sum of(value * count)). It's important to see that this 17 dosn't come from 9 * 4. It's =sum(I4:I6) (but it may be spread out like in 1200 FF example below! I am still trying to sort them both at one time, but I cant get past it..)
Add a helper column in D to combine the ID_1 and the first 2 characters of ID_2. =A4 & LEFT(C4,2). Copy that down then go to L4 and type in:
=+INDEX($D$4:$D$25,MATCH(0,COUNTIF(L$3:L3,$D$4:$D$25),0)
and hold down Ctrl + Shift + Enter to make it an array function. Copy down to get a list of unique combinations, and then split these values into the separate columns.
Finally to pull in the numbers, put this in Q4:
=SUMIFS(E$4:E$25,$A$4:$A$25,M4,$C$4:$C$25,O4 & "*")
and then copy down and across.

Excel with rows of details related to other row

There is a way to have a group of rows related to other one, in the same sheet, like a more detailed information? Obviously must keep them always next to the main row if you filter or sort.
Desired example based on vehicles and travels:
A B C D
1 [ID] [VEHICLE TYPE] [BRAND] [COLOUR]
+ 2 A-171 PICKUP HONDA BLACK
- 3 [TRAVEL] [KM] [STATION]
- 4 12/08/2016 13.000 BARCELONA
- 5 13/08/2016 13.750 DONOSTI
+ 6 B-501 VAN RENAULT WHITE
- 7 [TRAVEL] [KM] [STATION]
- 8 12/08/2016 117.800 PARIS
- 9 13/08/2016 120.000 AMSTERDAM
- 10 14/08/2016 124.320 MUNICH
So when you sort the spreadsheet, should keep always the travel rows next to the vehicle row.
It is that possible? If not, what can I do to get this or similar? (I don't mind to use other sheet tab, but it wasn't the ideal)
You can use the Group function (Alt-A-G-G), and they won't be sorted as usual if you use sort on the whole column

I want to get the sum of count of each unique entry from a particular column from google sheet

I have a google spread sheet,I want to get the sum of count of each unique entry from a particular column('Text' in this example).However the entries in the column themselves repeat.
Eg:
Text Count
a 3
b 4
a 8
abd 4
c 1
t 2
abd 5
a 2
v 1
v 67
w 44
I want the output as:
Text Count
a 13
b 4
abd 9
c 1
t 2
v 68
w 44
Under the assumption that you want to get the results in the text column automatically, use a Pivot table in Excel:
Mark your data including the column captions "Text" and "Count"
Go to the "Insert" tab in the ribbon, hit the arrow below and choose "PivotChart and PivotTable"
The cells for the raw data should already be entered. In the lower part of the window choose where you want to get the Pivot table. Then hit Ok.
There should be an area on the right-hand side of the window where you can choose which data you want to evaluate. Choose Text and Count.
There should already be the sum of the Count values. If you want to get a different quantity such as the average, hit "Sum of Count" with the right mouse button and
You need a GROUP BY and a SUM:
SELECT text, sum(count) as count
FROM yourtable
GROUP BY text

Resources