Excel: Multiple Vlookups to pull in 1 data element - excel

I have 2 separate sheets in Excel. On sheet 1, I am using the following if statement in column C (hours) to pull in a number in column D (hours) from sheet 2.
=IF(ISERROR(VLOOKUP(A2,Sheet2!A:D,1,FALSE)),"N/A",VLOOKUP(B2,Sheet2!A:D,4,FALSE))
The first vlookup is validating the project number on the second sheet, then the second vlookup is validating the team name and pulling in the hours from the second sheet.
The problem is that when I copy the formula down the column, the hours value repeats for the same team name. Does anyone have any suggestions?
Sheet 1
columns
Proj_Number Team Name Hours
123456 R&D 26
123456 Dev 50
123456 QA 10
777777 R&D 26
Sheet 2
Proj_Number Team Name Organization Hours
777777 R&D AUTO 26
123456 DEV AUTO 50
123456 QA AUTO 10
123456 R&D AUTO 20

You are asking VLOOKUP to do something that it cannot do. The second VLOOKUP in your IF formula:
VLOOKUP(B2,Sheet2!A:D,4,FALSE)
is being asked to return the first instance of 'Team Name' that it finds on sheet 2; which it is doing.
If you want to return the number of hours based on the 'Team Name' and 'Proj_Number', you need to do it a bit differently.
One way is to create another column on Sheet2, maybe called 'Proj_plus_Team', (inserted at column C location) that concatenates the values in 'Proj_Number' and 'Team Name'. Then you can search on this new column using the following formula:
VLOOKUP(A2 & B2,Sheet2!C:E,3,FALSE)
Also, when doing this, make sure that the data on Sheet2 is sorted alphabetically on the values in column 'Proj_plus_Team'. VLOOKUP requires that the search column be sorted alphabetically or inaccurate results may be returned.

Option 1 - using formulas
LOOKUP is designed to retrieve a single value, which is what it's doing. It loops through a data range, checking whether the value is bigger/smaller than the reference value, and retrieves the first transition point. In your case, it finds the first match and stops, not what you're after at all.
If you want to do this using formulas, you'll probably find SUMIF() and the newly added in 2007 SUMIFS() to be a much cleaner route. Also, side-note, in Excel 2007 Tables are your new best friend, they tidy the formulas for this kind of thing right up and look after things like expanding ranges.
Your example above, using tables, would be translated to:
=SUMIF(Table2[Team],Table1[[#This Row],[Team]],Table2[Hours])
where Table1 is the equivalent of your Sheet1, and Table2 maps to Sheet2
Of course the reason that this won't provide what you're after is that this is summarising by team only, whereas you want to apply 2 filters, so you'd move to SUMIFS() and end up with:
=SUMIFS(Table2[Hours],Table2[Proj_Number],Table1[[#This Row],[Proj_Number]],Table2[Team],Table1[[#This Row],[Team]])
The benefit is that your formula will always recalculate automatically, the downside is that you have to manually update your Table1.
Option 2 - pivot tables
Insert --> Pivot table will create your pivot table, set the range as appropriate.
Then drag Project Number into Row labels, drag Team name below it also in Row labels, and drag Hours into the Values box.
That'll give you a breakdown by project by team of how many hours. You can then mess around with the options to get it exactly how you want, by doing things like turning off the level 1 summaries. Those kind of options are best found by experimentation, they live in the PivotTable Design tab. The catch is the need to manually refresh the pivot table, the benefit is that when you add new projects they'll be taken care of easily.

Related

Two way lookup within a sortable/filterable Excel table

I am looking to return the intersection of a given row and column in an Excel table, where the sort/filter of the table will be changed.
I have found lots of resources on how to do a two way lookup in a static Excel 2D array/table that will never change order, but I am running into trouble trying to reference these intersections of a given row and column in a table that will be filtered and sorted by users. Filters and sorts are changing the cells' locations, breaking my references.
Ideally, the solution should look something like this:
=INDEX(TABLE,MATCH("PRODUCT",A:A,0),MATCH("COMPANY",$1:$1,0))
or, something like this,
=TABLE[[#Data],[PRODUCT] TABLE[[#All],[COMPANY]]
My environment is a table where the left most column is a list of products, and the top most row are column headers listing company names. The cell values at the intersection are quantities of products per company.
Thank you for any help, in advance!!
EDIT: Here's a visual example,
PRODUCTS COMPANY A COMPANY B
PRODUCT #1 1 2
PRODUCT #2 3 1
Referencing "COMPANY B", "PRODUCT #1" would return 2-- what's key is that the reference isn't broken by the table being filtered or sorted.
The first formula works, if made to select adjacent cell.
=INDEX(TABLE,MATCH("PRODUCT",A:A,0)-1,MATCH("COMPANY",$1:$1,0))
Revisiting later, it was selecting cell underneath the intended. Weird. Not positive why, but seems no one really took a look here. Folks at /r/Excel understood, though without any ideas as to why it picks cell below intended.

Matching mulitple criteria across 2 sheets and pulling some data from that match in excel

I have two sheets of data, one is a list of 4000+ companies and some data about the company (including a CUSIP and an issue date). The other lists stock prices per day for a said list of companies spanning multiple years.
I need to match the CUSIP and the issue date from the first sheet with that of the second and extract a number from sheet 2 where both where a match and put it in sheet one in a colomn next to the other data from that company.
Sheet 1
Sheet 2
I tried =VLOOKUP(E1076&O1076;Sheet1!A:Sheet1!K;11;FALSE) but all this did was give me a #NAME error same for when I tried to do this on the same sheet
I tried =INDEX(W:AP,MATCH(1,(X:X=D5)*(AE:AE=N5),0),42) but that just tells me it isn't a formula to begin with
Combined Sheets
In Column R:
{=INDEX(AG,MATCH(D2&N2, U&AB,0))}
will work for you but will likely be slow (make sure to enter with ctrl+alt+enter)
You can try and mitigate the lag by using defined ranged (e.g. U2:U4000&AB2:AB4000) but since your list is ever growing I'll guess that the lag will come back pretty quick.
To keep things faster, I suggest you use a helper column where you concatenate U and AB. Let's say column AC:
=U2&AB2
(copied all the way down)
You can then use a simple INDEX/MATCH:
=INDEX(=INDEX(AG,MATCH(D2&N2, AC,0))
You could also concatenate D and N to another column and use that column as your lookup value.

amounts and ageing in excel

I have two excel files that I need to cross reference amounts in.
The first sheet looks like the below:
what I need to do is find any amount that are contained on sheet 2 and the month they fall into.
Sheet 2 looks like below:
for example on sheet 1 I have 56.49 in column C for reference AK1080117 in column A and this shows as Person 8 on sheet 2.
I can see this is correct as on sheet one it has a transaction date of 08-jan and on sheet 2 is in the column JAN.
There is no same ref that can be used between sheet 1 and 2 as sheet 1 has Reference and sheet 2 has Name.
Can anyone advise the best way to do this.
The complete sheets are hundreds of lines long.
Many thanks,
Note: Make sure your data has unique values AND it is not exceding the year 2017
If so, I have found a way to maybe do this in a few steps:
1: Add another column E to your first sheet and add this formula to second row of the column and drag it all the way down:
=SUBSTITUTE(ADDRESS(1,MONTH(B2)+1,4),"1","")
2: Now create another column F next to the freshly made one and put this formula in second row:
=MATCH(C2;INDIRECT("Sheet2!"&E2&":"&E2);0)
3: Now create a third column G and put this formula in second row to be dragged down:
=INDEX(Sheet2!A1:D15;F2;1)
4: Now you have created a cross-reference because column G will show you the person with a match.
Edit: You can combine the three formulas direclty obviously but my personal preference is to brake things down to make them easier to understand :)
=INDEX(Sheet2!A1:D15;MATCH(C2;INDIRECT("Sheet2!"&SUBSTITUTE(ADDRESS(1,MONTH(B2)+1,4),"1","")&":"&SUBSTITUTE(ADDRESS(1,MONTH(B2)+1,4),"1",""));0);1)
Good luck with it!
You need a third table that has Reference and Name. Then you can use lookup functions or table relationships to link the data together.
Ask the source of the first table to include Name as a field.

Excel - Combining same names in 3 different sheets and adding their values

This is a project in school, sorry I just have a basic VLOOKUP knowledge in Excel. I have three sheets named: pasta, pastries and cakes. So basically this is a tally of how much we sell, and on the 4th sheet, we must list the TOTAL payment each person ordered from each of the 3 products above.
so in the images, those 3 sheets are the total payment each person must pay on each product. If you notice, there are duplicate names within the SAME SHEET and WITHIN THE 3 SHEETS. Like Joey's name appears twice on the pastries sheet, and once in the cakes sheet.
So basically i think you're getting my drift, I want in sheet 4 to appear all the payments joey must make in all three products. Basically determining/looking up all same names and adding all the values, then listing everyone else. The closest end I was able to achieve in consolidate was to create 3 more tables in sheet 4 with each product, VLOOKUP all info, create a 4th table in sheet 4, and do consolidation (see sheet 4). But the problem is other than the fact that it is such a mess, they do get consolidated, but only after the consolidate program is entered. But if another input was made in the other 3 sheets, lets say joey buy 3 more pastas, it does not update anymore. Clicking create links in consolidation puts out an error.
I tried searching on youtube and forums stating the way of "Consolidate", but it always either messes up the whole sheet, adds a column in between, and other stuff. So I may want to do this in VLOOKUP way, so that it can be dynamic, meaning that the consolidation changes automatically EACH TIME an input is made/changed. And it is much cleaner, as I do not have to create 3 more tables in sheet 4 to show the summary of each product.
Consolidating names from individual sheets is not done in a straightforward way with formulae. You have to resort to VBA for that, which I assume is not in the scope of your project.
However, assuming that in sheet 4, you have all names lined up in the first column, the summation is easily done with SUMIF.
If this is your source sheet
In your new sheet, line up all names on column A, preferably sorted.
Add a column for each food item, say Pasta, Pastries.
Use this formula in each row.
=SUMIF(Sheet1!A2:A7,Sheet2!A3,Sheet1!B2:B7)
First column above Sheet1!A2:A7 is the list of names. Sheet2!A3 is the current name in question. Sheet1!B2:B7 is the amount due.
This would total each food item under that person. Finally you can have a total column to give the total across all food items. If needed hide the individual food totals. So finally, you might have something like below. Hide columns B and C in the end, if needed.

excel - advanced vlookup or other formula?

I have a question regarding excel and I am looking for a formula that can help me transport my data from one sheet to the other. I have some experience with excel, however I am not a pro at it, so I apologize if this is a very trivial question but would also be happy since that would mean it probably has a very trivial answer! Unfortunately I do not have enough reputation points yet to post images, but I will try to explain it as clearly as possible.
Basically I am creating an excel template and the goal is to have 2 sheets in excel.
In the first sheet I have a column with following input in rows A1 - A3: Sales Region,
Country, Account ID's.
Above is the example of column A; from column B --> x; I will put e.g.
Americas, US and as many account numbers as there are in that specific country.
However on the second sheet it gets a bit complicated. My goal is that all the account numbers from sheet 1 irrespective of their sales region and country (which also means irrespective of their column) will automatically be listed on the second sheet.
The second sheet will be organized in the following way:
From column A - C; sales region, country and account ID.; from column D - x financial information for each account.
As a first step I want all the different account ID's from the different columns on the first sheet to be listed under column C (account ID's) on the seconds sheet.
As a second step I want column A - B to be automatically filled out according to account number by accessing the information in which column and thus sales region and country the account is in on sheet one.
I don't think a simple vlookup would do the job, especially for step 1, since I want the account ID's from many different columns and rows in sheet 1 to be listed in just one column....
hope it is clear enough! Would appreciate any help! :) thanks in advance!
The first step take all of column A and copy it to the 2nd sheet on column C.
Select data ribbon and select remove duplicates.
For column A insert vlookup for column C for all the data in 1st sheet
For column B insert vlookup for column B for all the data in 1st sheet
Those value will work well only if an ID has one valid Region and country.
Now just use custom sort to sort it in the way you desire.

Resources