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

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

Related

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.

find longest string in with criteria - excel

I have two columns Item and ID - refer to the Sample Table. I need a formula in Excel to determine the longest (based on simple length of ID) per item.
Here is what I am trying to extract from the sample table:
Item 1 ABCDABC
Item 2 XXXYZ
I tried index match combination:
=INDEX("ID column",MATCH(MAX(LEN("ID column")),LEN("ID column"),0),MATCH("Item 1" , "Item Column",0))
with ctrl+shift+enter
here are the results:
Item 1 ABCDABC
Item 2 #REF!
Any help will be greatly appreciated.
Sample Table
Item ID
Item 1 ABC
Item 1 ABCD
Item 1 ABCDA
Item 1 ABCDAB
Item 1 ABCDABC
Item 2 X
Item 2 XX
Item 2 XXX
Item 2 XXXY
Item 2 XXXYZ
This will return the correct index:
=INDEX($B$2:$B$11,MATCH(MAX(INDEX(LEN($B$2:$B$11)*($A$2:$A$11=D3),)),INDEX(LEN($B$2:$B$11)*($A$2:$A$11=D3),),0))
A PivotTable is perfect for this, because it will handle ties.
Turn your source data into an Excel Table
Add a new column to your source data, and use the LEN function to
return the length of each item. You only need to add the formula to the top row, and Excel will copy it down using Table notation:
Make a PivotTable out of that Table, and put Item and ID in the ROWS
pane and put Length into the Values pane:
Right-click on one of the cells in the Sum of Length PivotField, and
change the aggregation to MAX:
Click the ID filter dropdown, and select Values Filter > Top 10...
In the dialog box, change the 10 in the to a 1 and click OK:
BING!
...and if two IDs within the same category have the exact same length, the PivotTable shows you both of them:

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

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

Sort this data in excel kinda like a pivot

All,
I have this data I pulled from a database that I need to readjust. Here it is:
ID | Type | total
1 Purchase 12
1 Return 2
1 Exchange 5
3 Purchase 34
3 Return 4
3 Exchange 2
The desired result is:
ID | Purchase | Return | Exchange
1 12 2 5
3 34 4 2
and so on with a lot more data. Can this be done?
In Excel, format the data like so:
Choose a cell in these data, go to Insert -> PivotTable, insert it where you would like, and use the following settings:
This gives
Under "Design" in the Ribbon (make sure that your PivotTable is selected), go to Grand Totals -> Off for Rows and Columns. This gives
Click the "Exchange" cell and go toward the top of it, right below the "Column Labels" cell - you will see that the arrowhead will change and you can drag the column:

Group by Sum in Excel

Let's assume that I have the following table in Excel
A B
Item quantity_sold
A 3
A 4
A 1
B 5
B 2
D 12
C 3
C 7
C 8
and I need to sum up quantity_sold grouped by Item and print the results on the adjacent column only once per group, similar to the following
A B C
Item quantity_sold SUM_by_item_type
A 3 8
A 4
A 1
B 5 7
B 2
D 12 12
C 3 18
C 7
C 8
Is there any way I can achieve this without using Pivot Tables?
Try this formula in C2 copied down
=IF(A2=A1,"",SUMIF(A:A,A2,B:B))
That will give you a sum on the first row of each group - other rows are left blank
I'd create a smaller table alongside (or on a different sheet) and use
=SUMIF(A:A,"A",B:B)
where...
=SUMIF(different-item-range,"what you're looking for",things-to-add-together)
=SUMIF is all explained here: http://office.microsoft.com/en-gb/excel-help/sumif-function-HP010062465.aspx
Subtotal feature:
Click the Data tab in Excel's ribbon toolbar
Click the Sort button and sort by your category column
Click the Subtotal button and fill in the dialog as appropriate,
then click OK
Video example: https://www.youtube.com/watch?v=OBj30n_x5aQ

Resources