Lookup with multiple criteria, one a MAX value - excel

I am trying to lookup the LOCATION of an employee (NAME) and their MANAGER from the most recent month (largest month number) in a particular QUARTER in data like this:
NAME LOCATION MANAGER QUARTER MONTH
Ryan Smith Sioux Falls Rick James 3 7
Jane Doe Tampa Bobby Brown 3 7
John Rogers Tampa Tracy Lane 3 7
Ryan Smith Sioux Falls Rick James 3 8
Jane Doe Denver Thomas Craig 3 8
John Rogers Tampa Cody Davis 3 8
So if I know the name of the employee and the quarter I'm looking up, the results should display who their last manager was and the location they were in, as these may change month to month.
I have used an INDEX and MATCH array formula:
{=INDEX($B$2:$B$7,MATCH(A12,IF($D$2:$D$7=D12,$A$2:$A$7),0))}
but this just provides the first match and not necessarily the most recent month in that quarter. I attempted to include a MAX function which looked something like this:
{=INDEX($B$2:$B$7,MAX($E2:$E7,MATCH(A12,IF($D$2:$D$7=D12,$A$2:$A$7),0)))}
but that didn't quite get me there either.
What formula do I need to get this to work?

I think I'd choose a PivotTable for its versatility and speed:

I think a pivot table is probably the best option and can easily be modified with the filters when new entries are added to the underlying data. I was working on a solution with a formula, but it requires you to add a lookup column.
The formula for the lookup column is: =E6&" "&H6&" "&I6
I wasn't clear on how the OP was going to be "entering" his employee name and quarter, so I had to make an assumption that it would be in a separate column:
And the formula in column B (which is cumbersome) is:
=VLOOKUP(A6&" "&MAX(IF(H1:H100=NUMBERVALUE(RIGHT(A6,1)),I1:I100)),$D$6:$G$11,3,FALSE)&", managed by "&VLOOKUP(A6&" "&MAX(IF(H1:H100=NUMBERVALUE(RIGHT(A6,1)),I1:I100)),$D$6:$G$11,4,FALSE)
But it works, and as long as the lookup range is adjusted, is scaleable.

Related

Dynamically sum cells whose neighboring cell contains certain text

In my spreadsheet, I am tallying expenses made by John, Bob, and Simon for a project.
When John records an expense, it must contain his name (not case sensitive):
A B
Apples(John) 50
Simon makes 90% of the expenses and doesn't always write his name down.
At the end of the project, an expense list might look like this:
A B
Apples(John) 50
Toy (bob) 15
Pencils John 30
Metal 10
Peaches (simon) 5
Donuts BOB 30
Without using macro's (which don't work on Android's Excel app), how can I dynamically sum their expenses as each new entry is entered?(I am logging expenses on the desktop and on the phone, synced through the cloud). I would like one cell for each team members total. This is tricky for me because I have to sum items in B if its corresponding entry in A contains a certain text. Something like:
Totals:
John 80
Simon 15
Bob 45
SUMIF() function will meet your requirement. You have to use wildcard in criteria part as names are mixed with item name. Try below formula.
=SUMIF($A$1:$A$6,"*" & D1 & "*",$B$1:$B$6)

Excel - using INDEX / MATCH to retrieve data from a table based upon multiple matches

I have a rota listing names (down the side) and dates (across the top) and there is also an additional column for region/area for each name e.g.:
--Name--------Region-------13/12/19--------14/12/19--------15/12/19--------16/12/19-----------17/12/19
John Smith North IN IN OFF IN OFF
Jane Doe North OFF IN IN IN OFF
Bob Newhart South IN IN OFF OFF OFF
I also have a list of jobs completed by each person e.g.:
--Name--------Region-----Job#---CompletedDate-----JobType
John Smith 22 14/12/19 xx
John Smith 23 14/12/19 yy
John Smith 24 16/12/19 zz
Bob Newhart 25 14/12/19 aa
I know how to look up the Region from the name =INDEX(table[Region],MATCH(A2,table[Name],0),0)
and I've even worked out how to look up whether they're in or off based on a 2-way INDEX/MATCH (e.g. =INDEX(Rota!B:B,MATCH(A2,Rota!A:A,0),MATCH(D2,Rota!1:1,0))
My issue is when a person changes region e.g. John Smith moves from North to West:
--Name--------Region-------13/12/19--------14/12/19--------15/12/19--------16/12/19-----------17/12/19
John Smith North IN IN OFF
John Smith West IN OFF
Jane Doe North OFF IN IN IN OFF
Bob Newhart South IN IN OFF OFF OFF
I need to look up what their region was on the day the job was done so I can summarise the jobs done per region separately from the number of jobs done per person.
I'm guessing that it is something like the 2nd INDEX/MATCH above but with some form of "if the cell is blank then move down to the next match of their name in the same column". Does that even make sense?
Any help would be appreciated.
Thanks,
Alan
What about creating a helper column that combines person + region? e.g. you'll have a (hidden) column containing values like John Smith~north (you'll want a separator that properly handles Jane South).
Additionally, I think the first index function you've created can be substituted by a VLOOKUP:
=VLOOKUP(A2,rota!$A:$E, 2, FALSE)
// look for value A2
in the first column of A:E on the Rota sheet, then
copy over the value from the 2nd
Don't approximate matches
The second could be re-created with a simple COLUMN() reference to itself if the dates are entirely congruent between the sheets (i.e. if the dates are the same for each column).
EDIT
Took a second (closer) look - You're kind of pushing Excel to the limits of what it is designed for. You could try and hack around this, e.g. by wrapping the second INDEX function in an IF that checks if the outcome of the index is not empty and if it is, moves the match down one. But this will not tackle an example where John moves between three regions.
Conceptually, you're working on three tables:
1. Name/date with in or out values
2. Name/date with region values
3. Job/date with name values
Because your ROTA table is merging 1 and 2, you are getting multiple rows for one individual, and that is giving you trouble in the third table. Maybe in your design you can split these, which will make it easier to grab them with the functions you use. This starts to look a lot like a database though...
But maybe you add the region in the fields of the ROTA table?
--Name----------13/12/19--------14/12/19--------15/12/19--------16/12/19-----------17/12/19
John Smith IN~N IN~N OFF~N IN~S OFF~S
This means that for the region you can use the function that you'll already used, if you use one appended character in all cases:
=LEFT(INDEX(table[Region],MATCH(A2,table[Name],0),0), LEN(INDEX(table[Region], MATCH(A2,table[Name],0),0)) -2)
=RIGHT(INDEX(table[Region], MATCH(A2,table[Name],0),0), 1)
Or if you want to use the delimiter (~ in the example)
=LEFT(INDEX(table[Region],MATCH(A2,table[Name],0),0), FIND("~", INDEX(table[Region],MATCH(A2,table[Name],0),0) -1)
=RIGHT(INDEX(table[Region],MATCH(A2,table[Name],0),0), FIND("~", INDEX(table[Region],MATCH(A2,table[Name],0),0) -1)

Formula to find out how many times accounts transacted on the same day

I am looking for a way to find out which accounts appear to transact on the same days together the most.
I have looked into using the correlation function, but decided this would not provide the results I am looking for as I would need to be able to do this among the 6000+ different acct #s. Therefore, I have decided to try to solve this by creating a matrix of the account #s and finding out how many times each account transacted on the same day as another account, but I am open to other ideas of solving this if anyone has a better idea.
My source data is a large dataset consisting of 2 columns - Date (Column A) and Acct # (Column B).
I am currently looking into sum product, but since I do not want to look at any specific date, rather the date range as a whole, I am not getting what I want.
=sumproduct(('Trxs'!A:A='Trxs'!A:A)*('Trxs'!B:B=A$2)*('Trxs'!B:B=$a2))
What I am looking for would be a formula that I could use to pull across a matrix of the acct #s that would add up the number of times each of the 2 acct #s transacted on the same date over the time span of a month and not using a specific date to figure this out by.
1/1/2019 123456
1/1/2019 987654
1/2/2019 987654
1/3/2019 123456
1/3/2019 123456
1/3/2019 987654
1/3/2019 567890
and the outcome would be
123456 567890 987654
123456 3 1 2
567890 1 1 1
987654 2 1 3
I've came up with a solution using a helper table that counts if that account had activity that day:
The formula for the cell F12 on the helper table is:
=+IF(COUNTIFS($B$3:$B$12,$E12,$C$3:$C$12,F$11)>0,1,0)
And the formula on the Final Resul table:
Edit 2: I agree with Domenic, the formula on cell F4 works better with the IF section:
=IF($E4<>F$3,SUMPRODUCT(INDEX($F$12:$J$14,0,MATCH($E4,$F$11:$J$11)),INDEX($F$12:$J$14,0,MATCH(F$3,$F$11:$J$11))),COUNTIF($C$3:$C$12,$E4))

Count Unique Entries in a Month for Pivot Table

Good afternoon,
I'm currently working on setting up a pivot table for chart that outlines an Average Revenue per Person by Line Type. Using the pivot table, I can sort everything out, but when I try to get a count of person, it adds all instances of that person's name up. What I want is that if the person's name appears once in a month, all other instances in that month of the person's name are not counted. But during a new month, the person's name will appear once more. So, it is somewhat like a unique count, but only unique per month.
My excel table looks something like:
A B C D
Date Person Revenue Line Type
1/1/2015 John $100 Toy
1/6/2015 Phil $200 Toy
1/6/2015 Jane $25 Garden
1/7/2015 John $50 Electronics
1/25/2015 John $10 Electronics
2/1/2015 John $10 Toy
2/17/2015 Phil $30 Garden
2/20/2015 Bob $500 Electronics
2/21/2015 Jane $100 Garden
So, as you can see, a person's name can occur more than one time in a month, and in more than one month. Currently, the code I am using for my helper column (E) is:
=1/COUNTIF($B:$B,B2)
This has only been giving me a count of patients throughout the entire year, not taking new months into account. I also have attempted this formula:
=IF(SUMPRODUCT(($B$2:$B2=B2)*($A$2:$A2=A2))>1,0,1
This only counts values that occur on the same day. I've tried adding in MONTH() checks and such, and am only getting syntax errors. I'm not sure where to turn for this one. Thank you!
Thanks to #TomSharpe's advice, I added a helper column to concatenate Month/Date and the Patient's name like so:
=MONTH(A2)&"-"&B2
Then used the original formula (below) to COUNTIF divided by 1.
=1/COUNTIF($B:$B,B2)
This gave me exactly what I needed.
Thanks again!

Excel Vertical and Horizontal view of cells

I am trying to create a booking system using Excel. I know this may not be the best option, however so far this is what I have come up with:
sheet1 with all customer details
sheet2 with all booking details
The customer id and name are ref to sheet2 so I don't have to type them again.
On sheet2 I have the customer name in column A and in Column B dates for different days laid out horizontally.
For example:
Customer Name Course 1 Course2 Course3
John Smith 01.01.2014 02.01.2014 03.01.2014
Bob Green 02.01.2014 03.01.2014 04.01.2014
The problem I am having at the moment is not being able to identify all customers who are booked on same date. For example if I want to see all the customers who are booked for 01.01.2014, how is that possible?
Any help will be great, or if you have better ideas about creating a booking systems suggestions are welcome.
You need to change your layout, then you can apply a filter. A better layout would be:
Customer Name Course Name Date
John Smith Course 1 01.01.2014
John Smith Course 2 02.01.2014
John Smith Course 3 03.01.2014
Bob Green Course 1 02.01.2014
Bob Green Course 2 03.01.2014
Bob Green Course 3 04.01.2014
Then just apply a filter on the Date column. To see all people in the same course and on the same date, apply a filter to both the Course Name and Date columns.

Resources