comparing two columns in excel (VLOOKUP not working) - excel

I have been breaking my head with this problem since morning and I haven't found a solution. Please give your valuable pointers if possible, so that I can try to find the solution.
I basically have two sets of data- an old list and a new list. I wish to compare the new list( comparing name and country together) with an old list, since the new list has a few additional entries. Later on, I would like to create a new list with common entries from both old and new list and add all the new entries below the common ones ( if possible, else I will do that manually later on but I would like Excel to tell me that this is a new entry). Sorry, if this has not been well explained, but maybe the following illustration helps
Old List
Item No. Name Country
1 Apples Italy
3 Banana Spain
4 Grapes Slovakia
5 Pineapple Greece
8 Banana Czech Republic
14 Apples India
23 Pineapple Hungary
19 Peach USA
2 Strawberries France
New List
Item No. Name Country
4 Grapes Slovakia
Mango Pakistan
14 Apples India
Oranges Mexico
19 Peach USA
2 Strawberries France
1 Apples Italy
3 Banana Spain
23 Pineapple Hungary
Avocado Netherlands
Expected Output:
List with common serial No.s based on common names from both lists
Item No.Name Country
4 Grapes Slovakia
14 Apples India
19 Peach USA
2 Strawberries France
1 Apples Italy
3 Banana Spain
23 Pineapple Hungary
Mango Pakistan
Oranges Mexico
Avocado Netherlands
As can be seen in this attachment, I have an old list with Item No., Name and Country. Let's assume that the item numbers have been classified based on some code words. In the second list, there are again Item No.s, Name and Country but some item numbers haven't been filled ( since they are new and have not yet been sorted). Now, I want Excel to compare the names AND countries of both data and provide the common Item No. output if there is a match. If there is no match, then I would like Excel to tell me that this is a new entry. I looked up on various forums and I realized that VLOOKUP command only allows me to search on Name OR Country would give me the common entries of Names/Countries respectively but not Item No.s. Is there any formula that could help me solve this problem?

Just paste the list together, then sort it, and then remove the duplicates. Removing duplicates is built-in into Excel starting from version 2007, you will find it in the Data ribbon (see http://office.microsoft.com/en-001/excel-help/filter-for-unique-values-or-remove-duplicate-values-HP010073943.aspx).

To use VLOOKUP just concatenate Name and Country, for example, B2 & "-" & C2. You can then do a lookup on the concatenated values in your source table:
VLOOKUP(B2 & "-" & C2,NewList!D2:E100,2,False)
This assumes that the concatenated column is in D in your new table, and that you've copied the numbers to column E (VLOOKUP can't look to the right). I put in the dash for readablility and to avoid the chance that a Country ends with a number, unlikely as that might be.

Related

Indexing multiple columns in Excel, return neighboring column

I am working on an excel sheet that will help me with meal-planning. Currently, I have my data stored in a manner like demonstrated below:
**Monday**
Breakfast Bagel 1 Cream Cheese 1
Lunch Spinach 1 Eggs 4 Cream Cheese 1
Dinner Pork 1 Eggs 2
**Tuesday**
Breakfast Cereal 2 Milk 1 Eggs 3
Lunch Bagel 1 Butter 1
Dinner Eggs 2
CURRENT OUTPUT:
Ingredients Needed:
Eggs 2
Bagel 2
Spinach 1
Pork 1
Cereal 2
Milk 0
Butter 0
Cream Cheese 0
Where the numbers represent the number of servings of each ingredient I need to buy.
The problem I am facing is that my current formula:
=INDEX($C$12:$C$58, SMALL(IF(ISNUMBER(SEARCH($B$60, $B$12:$B$58)), MATCH(ROW($B$12:$B$58), ROW($B$12:$B$58))), ROW(B1)))
Only indexes one row at a time. For example, if I am searching for how many Eggs I need to buy for the week, the formula would return 2 eggs (because it is only searching column B for Eggs and returning column C).
Is there a work-around that would allow me to be able to return the full number of ingredients I need to buy? I realize I could index each column individually, however, since I have many ingredients (100+), using my current formula doesn't seem feasible.
Any help is massively appreciated
You can use SUMIF, where the sum range is offset from the criteria range. For example, for simplicity, let's say that C12 to H19 contains the data (ingredient and quantity), try...
=SUMIF($C$12:$G$19,B60,$D$12:$H$19)
...where B60 contains the ingredient of interest. Notice that the sum range D12:H19 is offset from the criteria range C12:G19.

Combining like data on a spreadsheet

I'm not sure how I would go about creating a macro (or maybe even an Access query?) for what I'm looking at here. I have a spreadsheet of tens of thousands of customer names/numbers with product data. If a customer has bought two (or more) products, it reflects as multiple entries on the spreadsheet (example below).
Name # Product
----------------------------
Bob 101 Product 1
Joe 102 Product 3
Bob 101 Product 2
Bob 101 Product 3
Hank 103 Product 2
Susan 104 Product 1
Hank 103 Product 3
I want to run something on that spreadsheet that combines the entries into one line, such as the example below. I'm not concerned about how the "products" are delineated... comma, line break, space, whatever. But I would like the end result to look something like this
Name # Products
-----------------------------------------------
Bob 101 Product 1, Product 2, Product 3
Joe 102 Product 3
Hank 103 Product 2, Product 3
Susan 104 Product 1
But I'm not even sure where to start. Any ideas to at least get me in the right direction?
Sort on Product within Name and in D2 (?):
=IF(A1=A2,D1&", "&C2,C2)
in E2:
=A2<>A3.
Copy both down, select all, Copy, Paste Special, Values over the top, filter to select FALSE for ColumnE and delete all visible.

Excel: search two columns against another two columns to return a value fron a third

Got a bit of a pain. So got an interesting issue, basically. Have a long list of entities (200 plus) and I need to match them against a code which I have in another list. So from the entity list, I have the name and country of the entity (Name in column A, country in column D), I need to populate Column F with the code from the other list, or add unknown if a code cant be found.
So, tried to build the query by using the & operator
So =MATCH(A2&D2 to use as key, giving me a value like 'cool companyUNITED KINGDOM'.
In the second list (imported to sheet 2) contains the following columns
Code Name Country
So I want to search an array where Name and country have been combined:
=MATCH(A2&D2,Sheet2!B2:B99999&Sheet2!C2:C99999,0)
I then try to get the index back, so my complete list looks like
=INDEX(Sheet2!A2:C99999, MATCH(Sheet2!A2&Sheet2!D2,Sheet2!B2:B99999&Sheet2!C2:C99999,0))
And all I get back is #Value
Any suggestions
Edit: More infor
So sheet one looks like this (Its column C I need to populate from the code in column A, sheet two)
Entity name Status GIIN Country
Ben Dist Ltd NFFE N/a UNITED KINGDOM
Karamara Sdn Bhd PFFE N/a MALAYSIA
Farbion Trade (Curacao) N.V. LFFI N/a
Tentorim (International) B.V. LFFI N/a NETHERLANDS
Catamo B.V. TLTD N/a NETHERLANDS
Ben Dist Deutschland GmbH FLTD N/a GERMANY
Ben Dist Investments B.V. PFFE N/a NETHERLANDS
Ben Dist Limited TLTD N/a UNITED KINGDOM
Complete Solution Service Limited GLRS N/a UNITED KINGDOM
BDLT S.A. de C.V. TLTD N/a MEXICO
Telsa Telco Services SLTD N/a CHILE
And the second list will look like this
GIIN FINm CountryNm
AAAUG3.99999.SL.764 Asset Plus HSI Fund THAILAND
AABEIL.99999.SL.528 Gresham Capital CLO II B.V. NETHERLANDS
AAB36F.99999.SL.470 Maitland Malta Limited MALTA
AACRQK.99999.SL.756 BBGI GROUP SA SWITZERLAND
AADAD7.99999.SL.528 E-MAC DE 2009-I B.V. NETHERLANDS
AADDBX.99999.SL.060 GWD Limited BERMUDA
AAE9W5.99999.SL.764 Bualuang Money Market RMF THAILAND
AAGH8E.99999.SL.276 Sparda-Bank Baden-Wuerttemberg eG GERMANY
AAGR6U.99999.SL.438 Konsolidationsanstalt LIECHTENSTEIN
AAGWV3.99999.SL.360 BATAVIA PROTEKSI PRIMA 18 INDONESIA
AAGXH0.99999.SL.136 Monarch Capital Partners Ltd CAYMAN ISLANDS
AAHY1V.99999.SL.158 Pingtung County Farmers' Association TAIWAN
AAH0IZ.99999.SL.136 Diversified Absolute Return Fund CAYMAN ISLANDS
I suggest that you use following array formula:
= IFERROR(INDEX(List,SMALL(IF((INDEX(List,,2,1)=A2)*(INDEX(List,,3,1)=D2),ROW(List)-MIN(ROW(List))+1,""),1),1,1),"N/A")
To enter array formula in Windows use Ctrl+Alt+Enter.
On Mac keyboard use Command+Enter.
Then drag the formula downwards.
In this formula I have used named range List, which is equivalent to your Sheet2!$A$2:$C$99999. Named ranges make complicated formulas more readable and flexible.
If you do not want to use named ranges just replace List with Sheet2!$A$2:$C$99999.
=IFERROR(INDEX(Sheet2!$A$2:$C$99999,SMALL(IF((INDEX(Sheet2!$A$2:$C$99999,,2,1)=A2)*(INDEX(Sheet2!$A$2:$C$99999,,3,1)=D2),ROW(Sheet2!$A$2:$C$99999)-MIN(ROW(Sheet2!$A$2:$C$99999))+1,""),1),1,1),"N/A")
It works if your sheets look as follows:

Calculated column to show number of items selected in a multichoice field

In SharePoint I have a table with a lookup column that takes in multiple values. I am having a problem finding a code for a calculated column that counts how many values the user chose. For example,
Favorite Ice Cream
1 Vanilla; Chocolate; Strawberry
2 Cookies and Cream; Mint
3 Coconut; Chocolate; Butter Pecan; Strawberry
And an adjacent column will be...
Number of total Ice Cream
1 3
2 2
3 4
Thank you in advance!

Excel Charts for table with many duplicates

I have a list of names with 1000 entries and maybe 750 unique. There are other attributes, like location and position. Can I create a pivot table that would show me simple stat's like X number of unique people, X number unique in location 1, location 2, location 3, and finally x number of positions in location 1, position 2/location1, position 3/location2...?
Name Location Title
Smith, Bob UK Sales Manager
Smith, Bob UK Plant Manger
Jones, Keith UK Sales Manager
Jones, Keith UK Plant Foreman
White, Derick Denver Sales Manager
Brown, Frank Boston Supply Chain
Black, Jay Denver Sales Manager
Smith, Jeff Denver Sales Manager
Gonzalez, Al UK
Gonzalez, Al UK Staging Area Manager
Bright, Susan Denver Legel Secretary
Bright, Susan Denver Paralegal
Bright, Susan Denver Executive Assistant
Bright, Susan Denver Press Secretary
Alf, Jeff Denver VP, Sales
Green, Burt Boston VP, Sales
Jones, Chuck Denver Plant Foreman
Alten, Cory Denver Sales Manager
Clark, Jerry Boston Plant Foreman
Romo, Tom Denver Sales Manager
You may want to consider using CountifS functions in adjacent columns to the data. For example to count unique people, just create a column (call it column x for this example) and enter =Countif(Column A, A1) and copy down for all the rows. then just enter =countif(Column X, 1) and that should give you the unique names.
You can use CountifS function for more complicated counting logic to answer the other questions.
I have done similar counting of unique entries using pivot tables.
I create a additional column that has a 1 if it is the first occurance of the "key" (ie name). The formula is similar to this: (assume Column A has the "key")
=IF(ROW(A1) = MATCH(A1,A:A,0),1,0)
This formula is then copied down for every row (or if it's a proper table, it's auto copied!)
The idea is that the MATCH returns the row number of the first occurrence of "key". If it is the same as the current row, then count 1. If the values aren't the same, it's a duplicate, so give it a 0 value.
When you then do a pivot table sum on this value, it adds up to the number of unique entries. (ie unique names in a region.)

Resources