Trying add up values but have multiple entries - excel

I am trying to look up the value in one column and pull the number from another column.
Of course, I could use the simple V-lookup or Match.
However, the first column of data has multiple entries that are the same. If I Vlookup it is just going to pull the first number in the second column.
I need to pull each number from the second column and somehow add them together. Despite the fact I have multiple entries.
If there is a way to consolidate the multiple entries in 1st column while also summing up the numbers in the 2nd, that would be great.

I would recommend a Pivot Table. To create one, select a cell in your data range (which needs to have column names in the first row. Choose Insert / Pivot Table from the Ribbon and select the New Worksheet option for the location.
In the Pivot Table list on the new worksheet, drag the name of the first column to the Row Labels box and the name of the second column to the Values box. The name in the Values box should turn to Sum of <2nd column name>.
The Pivot Table will now show a sorted list of the column 1 values and the summed values of column 2. In the example, you'll see that

Does SUMIF do what you are looking for?

Related

Restructuring data in excel

I am trying to condense data in a specific way. I want any occurrences of the number 1 in each column to show up as 1 (regardless of how many times it occurs) with the corresponding site, in the corresponding column. Some sites occur multiple times in the original data, and I want to make it so that only one of each unique site shows up in the resulting data table with a 1 for the corresponding column if there any 1's in the column from the original data.
I would think it would be a vlookup function, but I have tried many different things and I am really stuck on this.
Image of original data and what I am trying to do:
Thank you
This assumes that your data set only contains 1 or blank and this approach uses a Pivot Table with MAX function. Below are details in case anyone doesn't know Pivot Tables.
Select a cell in your data and insert Pivot Table. Note, I added a title for column A, as you need that in the Pivot Table.
Click in the created Pivot Table and the PivotTable Fields dialog should pop up. If not, right click in Pivot Table and select Show Field List.
Drag the Field names (Code, a, b,& c) down to the appropriate blocks below. (Values under Columns will be created for you.)
Click on the drop down arrow next to each field name and select Max. That will rename it to "Max of ...". If that bothers you, then you can type the name you want into the Custom Name field. Note, it will not let you type the same name as the field name, eg a, but it will work if you put a space in front of it.
Given that the Pivot Table would be a lot of work for a large number of columns, here is a formula based approach. Put this formula in cell G2, then drag it down and across to fill your new table.
Note, you will have to populate all codes that you have in column F. And if any new codes are added later you will have to keep this updated. One of the advantages of a Pivot Table is that it will do this for you.
I know that you won't be putting this in these cells, so adjust accordingly. In fact, I would recommend this be in another sheet.
=IF(COUNTIFS($A:$A,$F2,B:B,1)>0,1,0)
COUNTIFS($A:$A,$F2,B:B,1)
This will count each occurrence when the value in column A matches your code $F2 AND the value in column B equals 1.
If that count is >0, then you know that at least one match was found and the IF will return 1, otherwise 0.

Finding Duplicates across a thousand lists

I have over 1,100 lists that each contain no more than 30 items in them. I am trying to see if there are any items within the lists that appear in all lists. I was initially thinking that I would need to compare the list in column A to the list in column B, store the duplicates, then compare the duplicates to the list in Column C, store the new duplicates, compare the new duplicates to the list in Column D, and so on until all the lists have been covered.
My questions are:
1.) Is this the correct way to approach this?
2.) If so, is there a simple VBA code that could be used to do this?
Deduplicate each list using Data > Remove Duplicates
Collate all the lists into one long list
Create a pivot table with the column of items as the Row dimension
Use the same column as the Value displayed in the pivot table, and aggregate using Count.
Sort the pivot table in descending order of that count.
The count shows the number of lists in which each item appears. If any have a count of 1100 then they must occur in every list.
Here's my non VBA solution to this fun problem. The plan is to search each item in any one list and compare to all the other lists in the table.
Start off by inserting a new "A" column to the left of your table. Copy any list and paste to A35.
if your goal is only to find items occuring in all lists, choose the smallest list.
if you would like to analyse, choose the largest list or even multiple lists.
you could include all items by copy/paste TRANSPOSE the entire table to new sheet. then you have less than 30 colums. copy paste each into one column and delete duplicates of this list with data--> remove duplicates.
Now you need to create a formula in cell B35 that searches for the string in A35 in the range B1:B30. You drag the formula all the way right and down.
=COUNTIF(B$1:B$30,$A30)
The results will be the count of each item found in each list. In order to see if any item is in all lists, then all columns within the specific row should count at least 1 item. To the right of the results, see what the minimum value in the row is with:
=MIN(B35:API35)
(assuming your table ends in column API)
If any of your rows have a minimum of 1, then the item is included in all lists.
You could then also sum up the line to see which items occur the most and you could use the "max" instead of "min" to see if any list has duplicates.
Please try to use this
If it will not work I can help you with Macro VB code.
Logic will be as below:
1. Keep 1st column as base to check all the other column
2. Check each 30 cell of the 1st column in a loop with all the other column cell.
3. Stop the loop, if you don't the value in an entire column.

Excel 2007. How can I convert names into unique IDs?

Currently I am forming a dataset in excel. With the dataset, I am going to do the panel regression using stata(fixed effect model).
However, I cannot change people's names into their unique IDs. In my dataset, I have name in column B, and I want to generate a new column A with corresponding numbers to names in column B. Doing manually is not an option for me since the number of data is larger than 1,000. Two particular problems I encounter are that names are in Korean so the number of characters are mostly the same, and there are same people in different rows. Is there any method that I could use?
If I understand you question correctly, I would do following.
Step 1: Used the Advanced Filter to filter on unique names
You can place these results on the same sheet or on a different sheet (as per Scott Craner's comment). Both options are listed below
Filter Names on the same sheet
Select all the data in column B, then click Data > Sort & Filter > Advanced.
Select the option to Copy to another location, Select a blank cell in column B location at the very bottom of your worksheet, several rows away from your data (since you won't be able to paste the results to a new sheet), and then select Unique records only. Then Click OK
Filter Names on a different sheet
Add a new sheet and the click Data > Sort & Filter > Advanced.
Select the option to Copy to another location
Set the "List range" to the column on your dataset sheet containing the names, and Set the "Copy to" range to B1 on your new sheet
Select Unique records only and then Click OK
This will paste a new range that has all the unique names in your list.
Step 2: Assign unique IDs to the names in the unique list
This can easily be done by entering '1' in the Column C cell next to the first name in the unique list, '2' next to the second name, selecting those two cells, and then clicking the bottom right corner of the selected cells and dragging it down to the bottom of the unique names list
Now you have a range (i.e. unique names and IDs) that you can use VLOOKUP to populate an ID column in your data set
Step 3: Use VLOOKUP to populate IDs for the rows in your dataset
For example, If your unique names and ID is in the range B1200:C1500, then you can enter the following formula in the first row of your dataset in column A (what you want to be the column with your unique IDs)
=VLOOKUP(B2, $B$1200:$C$1500,2,0)
After you drag this formula down your entire dataset, you'll now have the correesponding unique ID for each name.
Step 4: Cleanup
Copy your column A (should be all VLOOKUP formulas) and paste Values only so you don't have the formulas there anymore
Delete the unique data and IDs range at the bottom of sheet (or the new sheet you created to do this)

Excel formulas and conditional lookups based on multiple criteria and sheets

I have 2 sheets:
sheet_a is a styled print-ready layout for a single data record
sheet_b is a bulk data table which is continually growing. Each row corresponds to a single complete record
Currently I am using a VLOOKUP to collect the data from sheet_b and put it in the respective cells in sheet_a. I have a drop down list on sheet_a which allows me to select a single record at a time to view.
Now I want to introduce a second drop down list to sheet_a where I want to select 1 of 4 specific conditions relating to the value of a cell in a specific column of each record on sheet_b.
I only want the entries that meet this condition in sheet_b to be made available in the range of records I can view on sheet_a.
Can anyone help?
As I understand it, you are looking for a way to filter the list that is used in the drop-down on Sheet_A.
add a column to the source data and calculate or mark manually which of the four conditions the record belongs to.
on Sheet_a add a drop-down field where the user can select from the four conditions. Name this cell "criterion"
in the source data table, add a column with a formula that returns the row number if the current row matches the selected criterion. Something like this copied down
=IF(B2=criterion,ROW(),"")
create another helper column that contains only the items that match the criterion using a formula like this and copied down
=INDEX(Data,SMALL($E$2:$E$18,ROW(A1)))
use a dynamic range name called "FilteredList" that contains only the values of the result list, not the errors. The formula for "FilteredList" is
=Sheet1!$F$2:INDEX(Sheet1!$F:$F,MATCH("zzzzz",Sheet1!$F:$F,1))
change the drop-down that is currently used to select a record to source its values from =FilteredList

Excel filter to new sheet

Looking for a way to automatically filter on a specific column and then for each filter in that column create a new sheet with that data.
I tried looking at using a pivot table and that works to some point if I filter my report on said column and then 'show report filter pages' but using the pivot is not the same as simplifying filtering the data...
Lets say I have 10 columns and 15 rows I specifically want one 'sheet' for each filter result based upon a filter of column H. So if there's no duplicates in column H I'd expect 15 new sheets.
What I do in that case usually is either make a pivot just to get all unique names or I copy-paste (value) the column on a separate column, call RemoveDuplicates() and go through that list.

Resources