Marking Duplicate Values based on additional cell. - excel

I am looking for a way, preferable formula based, to mark if a value(name) is present in a spreadsheet more than one time based on a difference in the order# in a different column. As there are multiple lines per order some names will have the same order# on multiple lines but I do not want to mark those only if there are multiple order#s for a person. Example below (new so might not be best formatting for site, sorry.) Thanks
ORDER# LN QTY ITEM LOC NAME DUPLICATE
OD10560 1 24 part#12 Location 1 Joe John Marked
OD10559 1 1 part#114 Location 2 Bunny Johnson Marked
OD10569 1 3 part#444 Location 1 Joe John Marked
OD10567 1 3 part#777 Location 2 Archy Bunker
OD10567 2 4 part#123 Location 2 Archy Bunker
OD10562 1 24 part#458 Location 1 Kay Harrison
OD10577 1 2 part#471 Location 2 Bunny Johnson Marked
OD10577 2 1 part#736 Location 2 Bunny Johnson Marked
OD10563 1 2 part#778 Location 1 Mark Riddle
OD10579 1 2 part#3347 Location 1 Terry Clark

COUNTIFS will allow you to see how many orders a person has, not including the current one.
The formula for MARKED would be:
=COUNTIFS($F$2:$F$11,F2,$A$2:$A$11,"<>"&A2)
in G2, and drag down.
This will count the lines where the person has the same name, but a different order. You can simply mark those that are greater than 0.
Note that this will show the second line as 2, as Bunny Johnson has 2 lines with different orders (it counts both of the other lines, as they have different order numbers, even though both of those lines have the same order). This does not alter the result in any way, just explaining why it shows 2 instead of 1 for everyone else

You could use the =COUNTIF(range, criteria) and just see if there are more than 1 counted.
Its pretty simple if you just take all of your names as the range and criteria is your name on the line you are looking at

Related

substitute a value in a cell with its class, Excel

I got two Excel database. One, regarding only cities and their land, has two main columns:
database1
city land
1 1
2 1
3 2
4 2
The other database shows observations and the city where they happened.
database2
- city
observation1 4
observation2 3
observation3 1
observation4 1
I'd like to substitute each cities with the corresponding land, to get something like that:
- city land
observation1 4 2
observation2 3 2
observation3 1 1
observation4 1 1
How do you think I can achieve that?
solved with xlookup (or cerca.x in italian), I'll show you how:
landdatabase2 =XLOOKUP(citydatabase2;citydatabase1;landdatabase1)
wonderful! thanks everyone

Excel - Counting cells from the range with multiple criteria (range + wild card)

I have the following table:
A
B
C
1
Match
Goals scored
Goals lost
2
Turkey - Italy
3
1
3
Turkey - Wales
1
2
4
Switzerland - Turkey
and I would like to count the number of matches that was won by Turkey.
Lets assume cell Z1 to contain "Turkey"
and
lets pay attention to the matches where "Turkey" is at the beginning of cells in A ("Turkey - ...")
I considered 2 ways:
=SUMPRODUCT(--(A2:A4=Z1&" -*"),--(B2:B4>C2:C4))
=COUNTIFS(A2:A4,Z1&" -*",B2:B4,">"&C2:C4)
In the first solution, it is not possible to use a range as 4th argument (">"&C2:C4)
However, in the second one, I can not use wildcard ("*"), because it is not allowed in sumproduct function.
How to solve this problem?
I will add that I don't want to write B2+B3+C4, because there is too much data in the whole table (and teams could be changed in the future).
First of all, you should use 2 Columns for the match.

Count occurrences of strings just once per row in Google Sheets

I have strings of spreadsheet data that need counting by 'type' but not instance.
A B C D
1 Lin 1 2 1
2 Tom 1 4 2
3 Sue 3 1 4
The correct sum of students assigned to teacher 1 is 3, not 4. That teacher 1 meets Lin in lessons B and D is irrelevant to the count.
I borrowed a formula which works in Excel but not in Google Sheets where I and others need to keep and manipulate the data.
F5=SUMPRODUCT(SIGN(COUNTIF(OFFSET(B$2:D$2, ROW($2:$4)-1, 0), E5)))
A B C D E
2 Lin 1 2 1
3 Tom 1 4 2
4 Sue 3 1 4
5 1 [exact string being searched for, ie a teacher name]
I don't know what is not being understood by Google Sheets in that formula. Does anyone know the correct expression to use, or a more efficient way to get the accurate count I need, without duplicates within rows inflating the count?
So this is the mmult way, which works by finding the row totals of students assigned to teacher 1 etc., then seeing how many of the totals are greater than 0.
=ArrayFormula(sum(--(mmult(n(B2:D4=E5),transpose(column(B2:D4)))>0)))
or
=ArrayFormula(sum(sign(mmult(n(B2:D4=E5),transpose(column(B2:D4))))))
Also works in Excel if entered as an array formula without the ArrayFormula wrapper.
A specific Google Sheets one can be quite short
=ArrayFormula(COUNTUNIQUE((B2:D4=E5)*row(B2:D4)))-1
counting the unique rows containing a match.
Note - I am subtracting 1 in the last formula above because I am assuming there is at least one zero (non-match) which should be ignored. This would fail in the extreme case where all students in all classes are assigned to the same teacher so you have a matrix (e.g.) of all 1's. This would be more theoretically correct:
=ArrayFormula(COUNTUNIQUE(if(B2:D4=E5,row(B2:D4),"")))

Multiple Vlookup for identifying a customers name or business

I want to create a multiple vlookup to match records on an ID from two sheets. If the column reference does not exist I want it to look at a different column.
This is what I have already:
=IF(VLOOKUP(A2,'Roots data'!F$2:Y$1139,18,0)>0,VLOOKUP(A2,'Roots data'!
F$2:Y$1139,17,0))
18 being the column which I want to check first and 17 being the column I want to check second. Can you please advise why this is not working appropriately?
Sample data:
Table 1:
ID First Name Last Name Age/Road
1 James John
2 John Miller
Table 2:
ID Age Address
1 21 1 Road
2 22 2 Road
In this example, if I wanted to find the Age of ID 1 which is James I would do a vlookup to identify this, if the age was not present I instead would want to know the address for ID 1, to be populated under Age/Road in Table 1.
I believe this is what you are looking for:
=IF((VLOOKUP(A2,'Roots data'!F$2:Y$1139,18,FALSE)=0),VLOOKUP(A2,'Roots data'!F$2:Y$1139,17,FALSE), VLOOKUP(A2,'Roots data'!F$2:Y$1139,18,FALSE))

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