Hopefully this is an easy question: I need to combine some similar rows in a spreadsheet but I need to add the values in one of the columns. For example, the data looks like this:
Result Count ID
100 75 xxx
100 10 xxx
100 5 xxx
95 35 yyy
95 40 yyy
95 10 yyy
I would like to combine all rows so that there is just one row for ID xxx and one row for yyy so that the final spreadsheet would look like:
Result Count ID
100 114 xxx
95 75 yyy
I know that I could probably use sum but I'm dealing with several thousand rows of data and was wondering if there is a way to do this more quickly.
Your example does not make sense, the numbers don't add up. Can you also have something like:
Result Count ID
100 114 xxx
95 75 xxx
80 70 yyy
I guess you could get very far with pivot tables. There are many other ways but pivot tables are more visual and easily customisable.
Select your data, go to the Data menu and click on Pivot table. The pivot table builder will pop up. Drag the ID column into the Row Labels list, drag the Count into the Values list and Result into the Row labels list again.
You can actually slice and dice your dataset any way you want with the pivot tables. To learn more just pop-up the help(F1) for pivot tables and follow some examples.
Related
I would like to extract a price value based on two other columns. In table 1, I am given the raw data where I want to draw from. In Table 2, I am given only the contract number, and I would like to find the type being "Mater" and have the price listed out for it.
I've tried to use this formula but I don't think I am calling the columns correctly.
=IF(AND(Table2!A1=Table1!$A$1:$A$6,Table1$C$1:$C$6="Mater"),Table1!$D$2:$D$6,"")
Is there a formula using index match, if(and), or another one that could work in this case?
Thank you!
Table 1.
Contract
Work
Type
Cost
5321a
aaa
Labor
52
5321a
ab
Mater
57
5641a
aba
Mater
10
536451a
aae
Labor
75
2441a
aan
Labor
42
53421
aar
Mater
14
Table 2
Contract
Mater Cost
5321a
57
5641a
57
53421
14
The following should work:
=SUMIFS(Sheet1!D2:D7,Sheet1!A2:A7,A2,Sheet1!C2:C7,"Mater")
(I'm assuming the first table in on Sheet1)
I am giving a homework exercise that the student can submit in singles or pairs. The solutions are submitted in a Google form with three fields: submitter1, submitter2 (optional), solution. The submissions automatically go into a Google spreadsheet with four columns: submitter1, submitter2, solution, and grade (filled in by the TA). For example:
submitter1 submitter2 solution grade
111 222 x 100
333 y 90
444 555 z 80
I would like to create a second sheet that automatically lists the grades of each submitter alone, e.g:
submitter grade
111 100
222 100
333 90
444 80
555 80
The order in the second table is not important.
Is there a way to do this in Google spreadsheet?
Alternatively, is there a way to do this in another spreadsheet software, such as LibreOffice Calc or Excel? (in that case I could copy the spreadsheet to that program and do the calculations there, though it is less convenient than doing it directly in Google spreadsheet).
EDIT: The main problem is to collect all submitter IDs into a single column. I do not know in advance how many submissions there will be, and how many of them will be single/pair. I tried to put in the "submitter" column:
=IF(ISBLANK(Sheet1!A2),Sheet1!$B$2,Sheet1!A2)
and copy it downwards. This gives me all the first-submitters, and then the first second-submitter. But then how to automatically take the next second-submitters?
List the submitters with this in A2,
=ArrayFormula(UNIQUE(TRANSPOSE(SPLIT(CONCATENATE(Sheet1!A2:B&CHAR(9)),CHAR(9)))))
Retrieve their grades with this formula,
=index(Sheet1!D:D, iferror(match(A2, Sheet1!A:A, 0), match(A2, Sheet1!B:B, 0)))
Linked google-sheet here (updated)
=UNIQUE({{Sheet1!A:A,Sheet1!D:D};{Sheet1!B:B,Sheet1!D:D}})
Arrange arrays and do the formulas. QUERY to remove blanks, if needed:
=QUERY(UNIQUE({{Sheet1!A:A,Sheet1!D:D};{Sheet1!B:B,Sheet1!D:D}}),"Select Col1,Col2 Where Col1 is not null")
If I'm trying to find specific names in a list given from my pivot table such as -
Row Labels Revenues Order #
Panera 25 0
Pasta 15
Salad 10
Olive Garden 40 0
Sandwich 20
Pasta 20
Panda Express 30 0
Rice 15
Chicken 15
And I want to search through my document, find Olive Garden and Panda Express and I wanted to replace the 0 in the order # column with 10 for Olive Garden and 20 for Panda Express. Currently, someone here helped me out with
=IF(IFERROR(VLOOKUP(A9,worksheet!K:K,1,FALSE),"")="","",0)
which inserts 0's for the headers and blanks for the orders in the 'Order #' column, can I add a second formula that would find the names and replace the value in that column? Or adjust the current formula?
Quick note - order # column is not from the pivot table.
To make it more clear, - I am getting data from an external source (i.e. paper invoices), as opposed to making a manual entry to adjust the 0's in the order # column, I would like to tell VBA/Excel - "hey Olive Garden's order number is 10 and Panda Express's order number changed to 20, adjust".
this is my end goal -
Row Labels Revenues Order #
Panera 25 0
Pasta 15
Salad 10
Olive Garden 40 10
Sandwich 20
Pasta 20
Panda Express 30 20
Rice 15
Chicken 15
If you have a range with the restaurant names in one column and the order numbers in the next column (say columns X and Y of the sheet called "worksheet"), you could change your formula to be
=IF(IFERROR(MATCH(A9,worksheet!K:K,0),"")="","",IFERROR(VLOOKUP(A9,worksheet!X:Y,2,FALSE),0))
(P.S. Changed the original VLOOKUP to MATCH based on useful feedback from teylyn.)
FWIW, that formula would be better using MATCH, not VLookup, since it's returning the value from the first column.
But back on track: what are you trying to achieve? Change the values in a pivot table?
First, a formula cannot change values in another cell.
Second, a pivot table reports on existing data. You can't change the numbers that a pivot table reports.
You will need to re-think your approach. If you don't like the numbers the pivot table returns, you'll need to change the underlying source data.
Been trying to figure this out for a while -
If I have a situation in which my pivot table gives me something along the lines of:
Row Labels Revenues
Panera 25
Pasta 15
Salad 10
Olive Garden 40
Sandwich 20
Pasta 20
and I wanted to insert a column next to revenues with 0's only for the rows with headers (panera, olive garden) and leave the rest of the rows for the orders blank - i.e.
Row Labels Revenues Order #
Panera 25 0
Pasta 15
Salad 10
Olive Garden 40 0
Sandwich 20
Pasta 20
is there a way to do this either in VBA, or just with a formula? Within my pivot table, the headers are labeled "restaurant name" while the subsets are labeled "orders", I was thinking about saying something along the lines of - if it's a restaurant name, insert 0, otherwise leave blank - but not sure how to do that or if there's an easier way?
If there is no overlap of names of restaurants and names of orders (i.e. you don't have a restaurant called "Pasta" for instance), you could use a formula such as
=IF(IFERROR(VLOOKUP(A3,'Sheet2'!A:A,1,FALSE),"")="","",0)
(assuming your pivot table was extracting the original data containing the restaurant name from column A of Sheet2)
My Excel sheet contains columns for id, date, amount and name.
If two or more rows have the same id and name I want to merge them into one row with the amount of those two combined. Can anybody help me doing this?
Use concatenation with Columns ID and NAME (=ID&NAME) in another column and look for the pivot table. Move to Insert->Pivot table option to get the attached answer]
Hope this clarifies
Here is a possible solution (as far as I understand the problem) using a PivotTable:
As you can see, there is not really much to it. Just insert a pivot table and drag the ID & Name to the Rows while you move the dates and the values to the Values section of the pivot table. The Values in the Column section will be automatically generated.
The only thing I changed at the end was to format the pivot table nicely doing the following:
Remove SubTotals by name
Using a PivotTable style that I like from the PivotTable menu in the section Design.
Show items in a tabular format. That means that the name and the ID are shown on one row and not in a cascading format (ID in one row and the name in a second row underneath + indented). You can achieve this by right-clicking on the name and selecting Field Settings. A new window opens (showing the settings). Go here to the Layout & Print tab and select Show item labels in a tabular form. You might have to repeat that for the field Name and the field ID (depending on which of the two fields you chose to show first in the Rows section of the PivotTable).
Let me know if this solved your problem or if you have any questions.
Note: since no sample data has been provided I made some up. I sure hope this data is somewhat similar to what you are trying to aggregate.
Used sample data:
ID Date Amount Name
1 05.03.2015 121 Peter
2 14.01.2015 127 Max
3 11.01.2015 77 Eva
4 06.11.2015 141 Jamie
5 04.03.2015 58 Sophie
1 04.04.2015 94 Peter
7 20.06.2015 52 Lucas
3 14.12.2015 136 Eva
2 02.11.2015 93 Max
10 20.08.2015 59 Mason
4 11.01.2015 145 Jamie
4 02.02.2015 113 Jamie
4 26.02.2016 89 Jamie
1 30.03.2016 137 Peter
15 09.09.2015 81 Jackson
16 25.02.2015 61 Liam
2 26.02.2016 133 Max
2 26.10.2015 80 Max
19 25.09.2015 76 Aiden