Multiple Responses in Excel's Reverse Lookup - excel

I'm trying to make a schedule of available workers after they have given me their availability. I would like a list generated of all people who say they can work on a specific day.
Ideally I would create some kind of list that looks like this:
I'm actually trying to schedule volunteers for my swim team, not employees, but the idea is the same. The form that they are filling out can also have blank spots (not shown in data table above, but possible) and the dates in the first column will also be out of order. I can manually fix both of those things, but if there is a solution that does not require me to fill in the blanks or sort the dates that would be ideal. I'm using Excel 2019 on a Win10 PC.

Starting in I2 you would have
=IFERROR(INDEX($B$1:$G$1,AGGREGATE(15,6,COLUMN($B$2:$G$7)
/(INDEX($B$2:$G$7,MATCH(I$1,$A$2:$A$7,0),0)="yes"),ROWS($1:1))-COLUMN($A:$A)),"")
so you are finding the right row in B2:G7 by doing a match on the date in column A, then finding the first, second, third... column which has a Yes in it, and finally getting the matching name from the first row.
You can see what's happening by stepping through the formula with evaluate formula:
(1) find the right row in B2:G7 by index/match
It's matching the date (stored as a number, 43466) against the list of dates in column A. The matching position is 1, which gives the row, and the column parameter in the Index function is 0 so you get the whole row.
(2) Find which cells contain 'yes'
The values in the array which do contain yes will be replaced with true and the ones which don't will be set to false.
(3) Do the division
This is the crux of the whole thing. What aggregate is going to do is to ignore the #div/0 entries (because we used option 6) and work out the lowest (minimum) column which corresponds to a 'yes', which is 2. It's the lowest because rows($1:1) just works out to 1 so you get the 'first smallest'.
(4) Adjust the column so that you get it relative to the first column of B2:G7. You could just subtract 1, but I'm trying to make it so that it still works if you insert a column to the left of the range.
5) Then all that's left is to index into the list of names in B1:G1
ending up with Albert.
As the formula is pulled down, rows ($1:1) changes to rows ($1:2) etc. so you get the second smallest column with a yes in it and so you get the second name. Eventually it errors out when there are no more matching names so IFERROR comes into play and you get a blank cell.

Related

Getting Top Values from One Sheet and inputting onto a different sheet

So I'm going to eventually have 3 sheets. Sheet 1 is where I have data (numbers for a category and a name associated with it. Sheet 2 is where I pull the top 5 users for each category. Sheet 3 is where I have a leaderboard for points gained.
Right now I'm trying to work with Sheet 2 (grab the top 5 performers from each category. I'm fairly new to Excel, but after some research it seemed that XLOOKUP would be the way to go. (i'll attach screenshots below.
I'm using this formula:
=XLOOKUP(LARGE('Cases Test for Categories'!$C$18:$C$55,1),'Cases Test for Categories'!$C$18:$C$55,'Cases Test for Categories'!$A$18:$A$55)
however when using it I get all 0's.
Here's a screenshot of values I'm trying to grab from "Warranty Service Request"
and here is a screenshot when applying my formula
The solution I would want is to grab the 5 largest numbers from sheet 1 with the person name as well.
I don't think that XLOOKUP can get you anywhere near what you want but the formula below will get you one step closer.
=INDEX(List,MATCH(LARGE(INDEX(List, ,2),1),INDEX(List,,2),0),1)
In fact, it's the explanation of that formula which will be of help. Here we go.
List is a named range, perhaps equal to your 'Cases Test for Categories'!$C$18:$C$55. The reason for using a name is obvious. It's shorter. In my test List = A2:B6, in case you want to reconstruct it. Column 1 has names, column 2 numbers.
The term INDEX(List,,2) specifies the second column of List. You can replace the '2' with a formula to specify different columns of the named range.
In fact, INDEX(List,,1) does specify the first column and INDEX(List,4,1) specifies the 4th cell in that column, and that is exactly what you see in my formula. All of MATCH(LARGE(INDEX(List, ,2),1),INDEX(List,,2),0) just serves to find the row number in List, in this example the number 4.
Of course, LARGE(INDEX(List, ,2),1) returns the largest number in column2 of List. The '1' can be replaced by a formula, for example ROW()-1 which would return 1 if placed in row 2 and count up from there as it's copied down. Try =ROW()-1 in any cell in row 2 and copy the formula down.
MATCH([LARGEST],INDEX(List,,2),0) returns the row number where the largest was found, and that is the number we need to return the name from the first column of List.
This will work perfectly for one column and can easily be modified to work for different columns. Your question doesn't specify how you would like to arrange the 5 results from each category but the formula can be modified a little to accommodate whatever you want. What it can not do is to deal with ties. MATCH(LARGE can only find the first of several identical results.
To break ties in this sort of operation is complicated and must be done ether by helper columns in the data table or using VBA. It's definitely the topic of another question. For now I hope that it's a problem you will not have to anticipate.

Production Calendar - Excel

I always bite off more than I can chew when it comes to my Excel knowledge. I am hoping someone could help me with this.
Essentially, I have two sheets, first is "Schedule" which is a data dump from MYOB with what we have on order with the warehouse to produce.
I then go through and plan what needs to be made on what day over a two week period.
I'd then like this to be put in a user friendly calendar in "Plan".
I thought of doing a comcatenate to make the week and day unique, and used an IF And formula. Then i realised all I am doing is making it look for the first line.
Is there a way to do what I am asking in Excel?
I guess what I want the calendar to look up a category, EG DUCT, then place anything with Duct in the respective concatenated calendar line.
spreadsheet can be found here
http://www.castekauto.net/stack/PlanningSchedulestack.xlsx
TIA
After some changes to the planning table which include:
Filling column A with Week-Day
Unmerging the column headers (for Duct for example)
Standardizing the fields you need (Composite Hose changed to Hose for example to match the Schedule worksheet)
I used the following array formula (entered with Ctrl+Shift+Enter):
=IFERROR(INDEX(INDIRECT("Table3["&C$6&"]"),SMALL(IF((Table3[Helper]=PLAN!$A7)*(Table3[STOCK CATEGORY]=PLAN!C$5),ROW(Table3[ITEM CODE])-8),ROW(7:7)-MATCH("zzz",$B$1:$B7,1)+1)),"")
Sample workbook uploaded here.
A bit of mumbo jumbo if you want to understand the formula break down a bit:
IFERROR(Result, "") simply will show blank if the result is an error (there are no more items that can be displayed)
INDEX(Column Result,SMALL(Matches, N)) Here Column Result is where the result of what we need comes from. It can be Item Code, Description or Quantity. Matches is a list of index for the rows that matched some specific criteria (Type of material, whether it's in the same week and day) and N is the Nth result we need. If N is 1, then we get the first result of the matches, if N is 2, we get the 2nd.
From the above, I used INDIRECT("Table3["&C$6&"]") for the Column result to make the formula a bit more flexible. When it is like this, the formula will decide which column it needs to return, whether it's the Item Code, Description or Quantity.
Matches is defined by IF((Table3[Helper]=PLAN!$A7)*(Table3[STOCK CATEGORY]=PLAN!C$5),ROW(Table3[ITEM CODE])-8) which basically checks if the week and day matches, together with the Stock Category. If both matches, then return the row number of those rows (the result is an array).
N is defined by ROW(7:7)-MATCH("zzz",$B$1:$B7,1)+1), which is kind of a small algorithm I've used so that after each new day, I get a new N starting at 1, that increments by 1 until a new day is reached. It basically takes the current row, subtract the last row up to the current row from column B and add 1. If the two are on the same row, the result would be 1. If the current row is one row below the last row from column B, the result will be 2, etc.

Return last date something was entered into one column with criteria from another column

I'm working with a set of data in excel. Data is entered into rows for items specified in columns. The first column contains a date. A cell in the same row of one of the columns contains the name of a person and in another cell in the same row but different column may contain a number larger than zero (or it may be empty).
I need to create a formula which returns the date when a number larger than zero was last entered into that column for a specific name. This is a "living list" which keeps on growing and the same names appear in different rows, sometimes with a number in the column a mentioned and sometimes not.
I found an old thread on this site on a similar subject which got me as far as knowing the date of the last entry containing the persons name but I'm still not able to configure it to show me when that specific person also had a number larger than zero in that column.
Here's the thread: How to get the newest value from a column with conditions
My current formula looks like this:
=INDEX($A:$A,MATCH(MAX(IF($G:$G=Sheet7!C5,$A:$A,0)),IF($G:$G=Sheet7!C5,$A:$A,"")))
CTRL+SHIFT+ENTER
Column A contains the dates
Column G contains the names (and "Sheet7!C5" is a reference to a name)
The value column I need to add to the mix is column AY
I feel there must be a simple solution (a small add on to the formula) to solve this but I always end up with an error.
Thanks in advance :)
Edit: Here is a simplified example of the data entry and output list needed.
For this you need to sort the date DESCENDING and format the table as Excel Table
Edit: you can sort the date ascending. See explanation at the end.
Using your example, then the formula will be
=INDEX(TableData[Activity A], MATCH($B14, TableData[Employee initials], 0))
This works just like the usual VLOOKUP or INDEX MATCH, fetching the first date on an activity matching the employee initials.
You can use VLOOKUP, but you'll need to dynamically name the range of each columns.
Edit: Just today I found an interesting behavior of MATCH when it found multiple matching values. If you use 1 instead of 0, then it will fetch the last matching value on the list.
So, you can use this formula instead in ASCENDING table.
=INDEX(TableData[Activity A], MATCH($B14, TableData[Employee initials], 1))

Complex Lookup Function in Excel using 4 different lookup parameters

I am working on a project within an excel database and am trying to match 4 different properties which all have their own columns (A,B,C,D) to find a corresponding value on a different page (Sheet2!). One sheet 2 the values are once again found in their own columns (B,C,D,E) and if all of the values match I then want the value in column A Sheet2! to be displayed in column E on sheet1!
The problem is is that often times the values on Sheet1! will be able to match up with as many as 12 different unique rows on Sheet2! making this incredibly difficult with only intermediate experience in VBA. There can be duplicates that match all of the criteria. And for when this happens I would like to return the first item that matches, as long as a previous match was not made on that item.
To give you more information we have given products different values that designate where they belong based off their velocity. This has split them up into Section#, ShelvingType, Verticle, and Horizontal Location. And we are looking to match these values to the values of our previously existing locations that we have that have corresponding(matching) numbers or text values.
To go into even more detail, on sheet one we have the products with values on where they should go. One sheet two with have pre-existing locations for which products can go that have values that are represntative of that location. So, we want to take the products NEW location values off page one and match the existing location values on page two. The problem is that for every location there are up to 12products that could go there. So, we want to go in order saying that product1 goes in the first location with matched values while product2 goes in the next location with matched values, and so on and so fourth
Edited to remove previous responses
Based on your further elaboration, if I understand correctly, I agree with the comment left by #Aaron Contreras. You should create helper columns which show a 'unique ID' where all criteria match, as well as an additional helper column which increases as more items of the same criteria code are found. This will become the 'ultra-unique' ID for that item.
At this point I don't think array formulas will be possible, though I will leave in the answer which provides the result of the first matching criteria without further eliminating 'previously used' results. This could likely be further refined, but I doubt it would be more elegant than simply using the helper columns shown in my response below. At least, I can't figure out how to do it elegantly.
To summarize my assumptions:
-Your available space is in sheet1; column A contaions something like the location of that available space, and columns B-E contain criteria for anything which will be stored there.
-Your new list of items to be placed in a location is in sheet2; columnA will be where our formula goes, showing the available location to put that item.
Enter on Sheet1
In column F on sheet1, drag down this formula:
=B1&C1&D1&E1
This will create a unique ID key to be searched in the future.
However, as there will be multiple hits for the same criteria on sheet1 (because multiple locations can hold the same thing), we need to make each row 'more unique' by showing how many times that criteria combination has already occurred. This formula will thus go in column G on sheet1, starting in cell G1 and dragged down:
=F1&countif($F$1:F1,F1)
As you drag it down, this will count the nth time that the specific combination of criteria has appeared on sheet1.
Enter on Sheet2
Create the same columns in sheet2, in columns F & G. The formulas will be exactly the same, they will just refer to sheet2 instead of sheet1.
Then the formula in column A in sheet 2, dragged down from A1, would be:
=index(sheet1!A:A,match(G1,sheet1!G:G,0))
This will find the first time that all criteria match from sheet1, for the nth time that this criteria has been used on sheet 2.
Let me know if there is anything here I've missed.
Unfinished array method
Again, array responses are possible, but for your purposes likely unnecesarry; you should probably have a unique ID for all combinations anyway. However, in case you want to use the array method, you can like so (does not account for multiple locations being used; left for reference only if you want to take this up):
In sheet2, enter the following formula [confirmed with CTRL + SHIFT + ENTER instead of just ENTER, every time the formula is changed] on the row 1, with the different criteria (and copied down):
=index(Sheet1!A1:A100,match(1,(Sheet1!B1:B100=B1)(Sheet1!C1:C100=C1)(Sheet1!D1:D100=D1)*(Sheet1!E1:E100=E1),0))
This uses the inherent boolean logic of "TRUExTRUE = TRUE; TRUExFALSE = FALSE; FALSExFALSE = FALSE", to find the first row where there is a match of all criteria. Note that I have not made this go all the way down all columns, as with Array formulas this is a significant resource hog.
Assuming that your data starts from 2nd row (1st row for lables):
{MATCH(A1&B1&C1&D1,B2:B100&C2:C100&D2:D100&E2:E100,0)}
The above is an array formula, so you don't have to input the curly brackets {.
Simply press Ctrl + Shift + Enter after typing the formula
More info

Sort one column to match another in excel

I have a spreadsheet and I need to match the two columns together. However "Dove code" is 3600 rows and "code 2" is 1100. They all have the same codes as you can see in the image but you can also see where it starts changing and I need to have the codes all line up so I can see the gaps. I have already arranged them all alphabetically and its the "code 2" that would need to match up to "Dove code
If the above solution would result in too much shunting and vba is not an option, there's another way. Copy the first column and use 'remove duplicates' on it. Now you have an index list, put numbers from 1 to x in the column on the right of it.
Insert a column between the two lists and right of the second one.
Assuming that the index list is in F and the numbers in G, put this formula in the cell right of the first cell in the larger list:
=VLOOKUP(A2,$F$2:$G$500,2,FALSE)
Adjust the range accordingly. Put the same formula in the cell right of the first cell in the shorter list, with of course C2 instead of A2. Copy both formules to the end of the list.
Now both columns have an index on every row. You can match them using data sort, but for that you need to add dummies in the index columns.
Put this formula in the cell right of your basic index list: =countif(B:B,G2)
And this one in the cell right of that: =countif(D:D,G2)
Now you know how many times each record arises in both lists. Just add extra numbers manually so that both formulas turn up the same result. You should be able to do that really fast. If you have 200 records that are used 2 times in the first column and not in the second one, just copy the index of those 200 records and paste them twice. The countif's will automatically update.
You can use an extra column to calculate the difference between the two counts and use data sort on your basic index list to sort on the diferences.
After that just use data sort.
IF my directions are clear enough, this shouldn't cost you more than 10 minutes.
Edit:
Here's an example: http://img14.imageshack.us/img14/6366/k8pg.jpg
Without VBA I do this (for columns with a limited number of mismatches!) by adding a formula such as =INDIRECT("A"&ROW())<>INDIRECT("B"&ROW()) in a helper column. Working downwards, every time you see a TRUE shunt the appropriate column down to suit. But it may be only just about viable for 1100 rows!

Resources