Excel INDEX MATCH when one of multiple criteria is within a range of numbers - excel

To identify duplicates in a large list of personal records, I'm replacing all names with a CONCATENATE of Name and Date of Birth (DOB). Here is the sheet I'm referencing (DOBs!):
DOBs! -----------------------------------------
C D E F G I K
Name Years Start End # Yrs DOB NewNameDOB
Sally Adams 2014-2014 2014 2014 1 1968-1204 Sally Adams1968-1204
John Agnew 2014-2014 2014 2014 1 1979-0419 John Agnew1979-0419
Bob Anderson 2013-2014 2013 2014 2 1965-0402 Bob Anderson1965-0402
Antonio Andrews 2014-2014 2014 2014 1 1955-0716 Antonio Andrews1955-0716
Julie Assan 2012-2014 2012 2014 3 1978-0805 Julie Assan1978-0805
On the main sheet (Employees!), each person has a row of data for each active year. Work 14 years, you have 14 lines of data to track.
Employees! -----------------------------------------
C D **E** F G H I J...
Year Name NewNameDOB Dept
2013 Julie Assan Julie Assan1978-0805 East
1998 Mike Rogers Duplicate in Same Year Main
1999 Mike Rogers Duplicate in Same Year Main
2000 Mike Rogers Mike Rogers1969-0510 Main
2001 Mike Rogers Mike Rogers1969-0510 Main
As mentioned, I need to separate duplicate names from 10395 records (like Mike Rogers and Mike Rogers). Employees! column E will now identify the employees as Julie Assan1978-0805 and Julie Assan1980-0131 (for example).
Today we take my first step, using the years they worked in order to solve 99% of the duplicates. After this, only a few duplicate names will be left who worked at the same time as each other, which I'll have to handle manually.
If the Employees! sheet has a 2013 record for "Julie Assan," then the first step is to check DOBs to find any Julie Assans who worked in 2013. My new column E in Employees! will take the current 2013 record of Julie Assan, and find any matches in DOB! where C (name) matches Julie Assan, E <= 2013, and F >= 2013. Usually, there will be only one match, and it will tell me that is Julie Assan1978-0805. Sometimes, there will be two Mike Rogers who worked during the same year, and it should tell me "Duplicate in Same Year".
On the Employees! sheet column E, I've started with this...
=index(DOBs!$k$2:$k$10395,match($d3&$c3,DOBs!$c$2:$c$10395& ??? ,0)
Not sure where to go with this formula, whether that means adding "IFs" or something different.
edited to explain in great depth

=IF(COUNTIFS(DOBs!C$2:C$10395,Employees!D2,DOBs!E$2:E$10395,"<="&Employees!C2,DOBs!F$2:F$10395,">="&Employees!C2)>1,"Duplicate in Same Year",INDEX(DOBs!K$2:K$10395,MATCH(TRUE,IF(DOBs!C$2:C$10395=Employees!D2,IF(DOBs!E$2:E$10395<=Employees!C2,IF(DOBs!F$2:F$10395>=Employees!C2,TRUE))),0)))
Enter as an array formula by confirming with Ctrl+Shift+Enter, then autofill down. It first checks for duplicates using COUNTIFS, and returns "Duplicate in same year" if it is. If there are not duplicates, it uses INDEX/MATCH to find the NewNameDOB.

Related

Excel multi value counter

I couldn't find anything similar.
I have a pretty big excel table but I can't get what I need from it.
I have a column for example of names
John
Johnny
Arny
Arny
John
Johanatan
Jeremie
Brook
Arny
Johanatan
I want it to return or show me results like that
Johnny 1
Arny 3
John 1
Jeremie 1
Brook 1
Johanatan 2
Couldn't find an appropriate excel to result me with that.

List the next couple occuring birthdays in excel

Given the following data
A B
Steven 01/05/1958
Mike 05/12/1923
Bob 05/11/2001
Richard 10/22/1985
Maverick 12/25/1991
Ed 01/07/1954
I'd like to get a list in, let's just say the column D, containing the next couple birthdays that will occur.
So if today was 05/05/2016, I'd like to see
D E
Bob 05/11/2001
Mike 05/12/1923
My current approach (yet not working properly) is to create another column and have the days until the birthday calculated there, using this formula:
=DATE(YEAR(B2)+DATEDIF(B2+1;TODAY();"y")+1;MONTH(B2);DAY(B2))-TODAY()
Then I list the birthdays that come up in the next 5 days using:
=IF(ISERROR(INDEX($A$2:$C$5,SMALL(IF($A$2:$C$5<5,ROW($A$2:$A$5)),ROW(1:1)),2)),"",INDEX($A$2:$C$5,SMALL(IF($A$2:$A$5<5,ROW($A$2:$A$5)),ROW(1:1)),2))
I'd rather have the next 5 upcoming birthdays, no matter how far away from today they are.
Any Ideas how to achieve this without using makros?
Help is much appreciated!
To get the birthday difference from today in days :
=(DATEDIF($D$1,DATE(IF((DATE(YEAR($D$1),MONTH(B2),DAY(B2))>$D$1),YEAR($D$1),YEAR($D$1)+1),MONTH(B2),DAY(B2)),"D"))+0
The first BD from current date :
=VLOOKUP(SMALL(A2:A8,1)+0,A2:B8,2,FALSE)
Please see the img for more details :
Another approach would be to use the Advanced Filter. And you could automate it using VBA.
For the Criteria:
A2: =DATE(YEAR(TODAY()),MONTH(B6),DAY(B6))>=TODAY()
B2: =(TODAY()+$C$2)>=DATE(YEAR(TODAY()),MONTH(B6),DAY(B6))
Range is the number of days after today to show birthdays.
OK slightly different approach
Instead of counting days in a helper column, change the date in a helper column. Then sort that helper column for only the first 5 entries. This will show upcoming birthDAYS instead of birthDATES.
So assuming Names in column A, Dates in Column B, Column C is created with:
=DATE(YEAR(TODAY())+IF(TODAY()>DATE(YEAR(TODAY()),MONTH(B2),DAY(B2)),1,0),MONTH(B2),DAY(B2))
Now I was assuming no header rows and A1 was the first entry so to display the next 5 entries in column D I used:
=IF(ROW()<=5,SMALL($C$1:$C$6,ROW()),"")
Now this will not pull names but just the upcoming birthDAYS not birthDATES. The year being the difference between the two.
If you want to pull the names as well you can use the following:
=IF(D2<>"",INDEX($A$1:$A$6,MATCH(D2,$C$1:$C$6,0)),"")
Right now it will not return names of multiple people with the same date but there are ways around that. If you need that too let us know.
(A) (B) (C) (D) (E)
Steven 58/01/05 17/01/05 16/05/11 Bob
Mike 23/05/12 16/05/12 16/05/12 Mike
Bob 01/05/11 16/05/11 16/10/22 Richard
Richard 85/10/22 16/10/22 16/12/25 Maverick
Maverick 91/12/25 16/12/25 17/01/05 Steven
Ed 54/01/07 17/01/07
UPDATE
In order to deal with duplicate birthdays... try the following:
=IF(E5<>"",INDEX($A$1:$A$6,MATCH(E5,$C$1:$C$6,0)+COUNTIF($E$1:E5,E5)-1),"")
That was the entry for row 5. I tested it with the same birthdate, but I forgot to check for same birthday (different years).
UPDATE 2
NEW TABLE
The table below matches to formula from the last update
(A) (B) (C) (D) (E) (F) (G)
Steven 58/01/05 17/01/05 59 16/05/11 Bob 15
Mike 23/05/12 16/05/12 93 16/05/12 Mike 93
Bob 01/05/11 16/05/11 15 16/10/22 Richard 31
Richard 85/10/22 16/10/22 31 16/12/25 Maverick 25
Maverick 91/12/25 16/12/25 25 16/12/25 Ed 21
Ed 95/12/25 16/12/25 21
I inserted a column in D which shifted things right. The following was placed in D1.
=year(C1)-Year(B1)
In column G I had it lookup the age
=IF(E1<>"",INDEX($D$1:$D$6,MATCH(E1,$C$1:$C$6,0)+COUNTIF($E$1:E1,E1)-1),"")

Excel countif or if

Tried doing this a few ways and I think I'm just looking at this a little too complicated.
I have column a with several different names that repeat. I have column B with dollar amounts. I'm trying to get a formula that will add the totals amount for a specific person.
JOHN $17.23
JAMES $37.52
JOHN $14.23
JAMES $27.52
APRIL $32.00
APRIL $143.20
JOHN $90.27
JOHN $81.13
JOHN = Total for John
JAMES = Total for James
APRIL = Total for April
Thank you
Assuming this table
A B
1 Names Bill
2 John 10
3 Tom 20
4 John 4
5 Tom 3
To get the total for each name you can write
A B
7 Names Total
8 John =Sumif(A2:A5;A8;B2:B5)
9 Tom =Sumif(A2:A5;A9;B2:B5)
This will sum up each value for the given area.
Consider:
=SUMPRODUCT((A$1:A$8="John")*(B$1:B$8))
=SUMPRODUCT((A$1:A$8="James")*(B$1:B$8))
=SUMPRODUCT((A$1:A$8="April")*(B$1:B$8))
Striking my original response in favor of:
=SUMIF(B3:B10,"=JOHN",C3:C10) I tested that, and it works even better

Excel to find value from one sheet & show to another sheet

I have a sheet1 where column A= employees name & column B=Status (present, absent, etc), I prepare Daily attendance in each sheets, so I have 31 sheets in a month. Now I have a new sheet November. in this sheet column A is employees name and column B, C, D, etc for each days status. show me status of each employes in each days B, C, etc
You would use the VLOOKUP statement to fetch the status from the other sheets.
This is in the format:
vlookup([cell which has the value you want to lookup], [range of cells which contain the table], [column you want to return from that table]). Hopefully this is explained in the example below:
For ease of explanation, imagine your sheets are named Nov1, Nov2... Nov29, Nov30 and NOVEMBER.
Nov1:
A B
1 Employee Name Status
2 Albert Present
3 Brian Absent
4 Catherine Present
5 David Present
6 Edward Present
Nov2:
A B
1 Employee Name Status
2 Albert Absent
3 Brian Absent
4 Catherine Present
5 David Absent
6 Edward Absent
Then, in your sheet NOVEMBER, which is the month summary, use the formulae:
A B C
1 Employee Name Nov 1st Nov 2nd
2 Albert =VLOOKUP($A2,Nov1!$A$2:$B$6,2) =VLOOKUP($A2,Nov2!$A$2:$B$6,2)
3 Brian =VLOOKUP($A3,Nov1!$A$2:$B$6,2) =VLOOKUP($A3,Nov2!$A$2:$B$6,2)
4 Catherine =VLOOKUP($A4,Nov1!$A$2:$B$6,2) =VLOOKUP($A4,Nov2!$A$2:$B$6,2)
5 David =VLOOKUP($A5,Nov1!$A$2:$B$6,2) =VLOOKUP($A5,Nov2!$A$2:$B$6,2)
6 Edward =VLOOKUP($A6,Nov1!$A$2:$B$6,2) =VLOOKUP($A6,Nov2!$A$2:$B$6,2)
Using the $ symbol will mean you can copy down the column and the formulae will update automatically. Ensure that the list of employees in your separate daily sheets are in alphabetical order.
So this should result in something like this:
A B C
1 Employee Name Nov 1st Nov 2nd
2 Albert Present Absent
3 Brian Absent Absent
4 Catherine Present Present
5 David Present Absent
6 Edward Present Absent

Count names one time (per year) regardless of how many there are by year

The problem is:
There is a table that gets data added to it each month. I use this data for many different pivot tables and reports, so I am not able to modify it. The user has requested that if its possible (and I assured him that it was) he would like to see two (2) single values of This Year and Last Year Doctors on the list.
The data looks something like this:
Doctor, In/Out, Date, Number
John Deaux Out 10/1/11 8
John Deaux Out 11/1/11 3
John Deaux Out 01/1/12 5
John Deaux Out 05/1/12 3
John Deaux Out 09/1/12 1
Billy White In 02/1/12 2
Mike Adams Out 06/1/11 6
Mike Adams Out 10/1/11 9
Mike Adams Out 01/1/12 1
Mike Adams Out 04/1/12 6
I would have 1 John Deaux for 2011, and 1 for 2012. The same for Mike Adams.
TY 2
LY 2
Now I only have to count the "Out"(s), so I have to be careful of that. Also, there is the chance that I would have to build this for the previous 12 months as well making it that much harder.
1 for John Deaux for the previous 12 months.
TY 2
LY 1
*TY: This Year - LY: Last Year
To do this manually:
Since you can't make any edits to the existing table, copy everything to a new table.
In the new table, add a column called Year. Use the Year() function to get the year out of the date cell.
Make another column called Count. Use If(A2="Out",1,0) where A2 is the cell in the In/Out column.
Copy the Doctor, Year, and Count columns to a new table.
Excel 2007 and above has a convenient tool called Remove Duplicates in the Data ribbon. Use that to remove the duplicates. This will keep you from counting a single doctor twice in the same year.
Create a pivot table, using Doctor as the row, Year as the column, and sum(count) for the value.
Check this, this will check the B column for the year 2012/2013 and count the distinct unique values in column A.
=SUM(IF(FREQUENCY(IF(YEAR(B1:B11)=2013;A1:A11);A1:A11)>0;1)) + CONTROL + SHIFT + ENTER
=SUM(IF(FREQUENCY(IF(YEAR(B1:B11)=2012;A1:A11);A1:A11)>0;1)) + CONTROL + SHIFT + ENTER

Resources