assigning a value based on another column in Excel - excel

I am trying to find a quick way to assign a value for a column depending on the value of another.I want to increase the value of column A by one each time the value of column B changes.
Column A Column B
1 (520)998-7765
1 (520)998-7765
1 (520)998-7765
2 (450)877-4563
2 (450)877-4563
2 (450)877-4563
2 (450)877-4563
3 (650)989-7654
3 (650)989-7654
3 (650)989-7654
.... ....
I need to know if there is a formula that I can use to sort through 27,000 lines of data rather than assigning them one by one.
I am using a phone number as a unique identifier and I want the ID# to increase by one every time the phone number changes.
Please Help!!

Put value "1" in A2.
In A3 and after put the following function
=IF(B3=B2,A2,A2+1)
EDIT
You can make a single formula for all of the rows.
Put something like this in A2 and copy it down:
=IF(ROW(A2)=2,1,IF(B2=B1,A1,A1+1))

It seems like you are trying to extract the unique list of phone numbers? If so, there is a Remove Duplicates function in Excel (under the Data tab) that should do what you need.
You would select your full range (27,000 phone numbers) and run Remove Duplicates. Excel would then leave behind a single row for each unique number.
I believe Remove Duplicates is available for Excel 2007 or later.
If you are using an older version of Excel, here is a link that gives more information on filtering for a unique list:
Count unique values among duplicates

Related

Excel : Copy muitple columns to rows based on one column

I'm looking for the most efficient approach to transferring information from three columns to one row, right next to each other depending on the company name.
Consider the following example:
I have a 226k data list with product details for several customers (around 30-40k).
One customer can have 2 to 50 products, each with a serial number and a product number. Check out the source data pic.
Output required: One row per customer will have all the product data, serial number, and product number next to each other.
Source data
desired output
I have never used Macro. Can someone please help me find the best way to deal with this issue?
This one is pretty tricky, you'll need to play with column numbers to adjust formula:
The customer list in column F must be typed manually or if you have Excel 365 you may benefit from UNIQUE Function. I did it manually.
My formula in cell G2 is an array formula (must be entered pressing SHIFT+CTRL+ENTER or it won't work!
=IFERROR(INDEX(SI($D$2:$D$14=$F2;CHOOSE(COLUMN()-6-INTEGER((COLUMN()-7)/3)*3;$A$2:$A$14;$B$2:$B$14;$C$2:$C$14);"");MATCH($F2;$D$2:$D$14;0)+INTEGER((COLUMN()-7)/3));"")
Drag to right and then drag to down.
My formula uses the value 6 and 7 because my data starts at column G, that means column number 7. So if you put this somewhere else, make sure you change also 7 and 6 values to the proper values!
Anyways, I've uploaded a sample to Gdrive in case you want to check the formulas by yourself.
https://docs.google.com/spreadsheets/d/1TvNUVt0ArzyFK_jsRtZfX1ja2zUgSdhR/edit?usp=sharing&ouid=114417674018837700466&rtpof=true&sd=true

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.

Find out if a combination of 2 Cells values right next to each has been entered previously in 2 columns

So I have column A and B, we manually enter the values of this 2 columns to record when we change from Part A to Part B, if its in the file it means the change could be performed after some investigation. We do this manually every time a change of part number is requested.
To avoid this search with manual search or filtering, I want to know if its possible with an Excel Macro or a function to search in the whole columns if the combination of the values in, for example, A2131 & B2131 have been entered before (For example it was entered before in A1521 & B1521), and if yes, return a 1 or a yes, or anything that tells me it has been done before, and if it isn't, return something else.
I have tried to use vlook up, but I can only compare one column vs another, is there a way to compare 2 columns for example, which is what I need.
Not sure I understand exactly how you want these annotated, but you can use COUNTIFS to provide this analysis. Assuming your data begins in A2 and B2, you would put this formula in C2:
=IF(COUNTIFS(A:A,A2,B:B,B2)>1,"Duplicates","")
and then copy it down for all rows. Any row where both columns A and B match another row's column A and B will show the word "Duplicates" in column C of all matching rows.

HOWTO ad a unique id to each unique row?

I have data in two columns:
a 1
a 1
a 2
b 3
b 4
In the list there is 4 unique rows. I would like to ad a unique id to each unique row.
Like this:
1 a 1
1 a 1
2 a 2
3 b 3
4 b 4
Of course I have many more rows and columns and date are more complex than in this example.
Anyway to do this i excel?
Mvh Kresten Buch
I have the same issue, I have developed a three formula approach to this. I could probably concatenate it if I nested them, but whatevs, this works.
Assume the data you want to 'number' is in column A, and the first row of the table is row 3.
The first column (in column B) counts occurrences of the 'value' and the range expands from the top of the table downwards as the table grows:
=COUNTIF($A$3:A3,A3)
the second column's formula also expands as the row count does, and simply adds 1 to the transaction count every time it encounters a 1 (ie first occurrence of a new unique value) in column B
=IF(B3=1,MAX($C$2:C2)+1,"")
This one worked for me even in the first row of the table btw - i was expecting to have to manually input a 1 to start the list. Having it work without the manual entry is a good thing, it means the formmulas all work even if you resort the table data into a different order.
The third one in column D uses a vlookup to find the value. Note that when vlookup finds more than one number, it always pulls the first occurrence.
=VLOOKUP(A3,$A$3:C3,3,FALSE)
Note that this will renumber all the data outcomes dynamically if you do resort the entire thing. ie the formulas all work, but the number 'assigned' to a praticular set of data might be different, as it all works from whatever order the list of items is in.
My use case for these formulas assumes that every month i paste a new set of data to the bottom of the table, some items of which are repeats from previous months - ie are already in the table, and some of which are new.
if the dynamic renumbering is a problem, use a 'row key' so you can resort back to the original order at the end.
Assuming your data is in B2:C6 please try =IF(AND(B1=B2,C1=C2),A1,A1+1) in A2, copied down
If your data is not sorted, it's more complicated... but you can use something like this in A2:
=IF(COUNTIFS($B$1:B2,B2,$C$1:C2,C2)>1,INDEX($A$1:A1,IFERROR(MATCH(B2&"-"&C2,$B$1:B1&"-"&$C$1:C1,0),1)),MAX($A$1:A1)+1)
I'm assuming that there are no headers and you have already put 1 in cell A1 for the first record.
It basically checks the whole columns above the formula and if there's already a similar record, it'll assign the previously given unique ID and if not, it'll give a new ID.
This is an array function and as such will work if you use Ctrl+Shift+Enter and not Enter alone.
The IFERROR() is there because MATCH(B2&"-"&C2,$B$1:B1&"-"&$C$1:C1,0) would return an error if it is on row 2 (the first record to check).
Once you put that in the first cell, you can fill down the formula.
I deal with this issue all the time when structuring a data set into panel data. say you have multiple columns of data, and each are unique based on the name of someone, like:
ANNE
ROSE
ANNE
FRANK
TOM
ROSE
ANNE
but instead of having each column related to Anne, Rose, Frank, or Tom, you want it to look like this:
1 ANNE
2 ROSE
1 ANNE
3 FRANK
4 TOM
2 ROSE
1 ANNE
So that each name now has a unique numerical identifier that can be used in place of the name.
Make a pivot table of your data and only place the column that has the names (or whatever the identifier may be) into the Rows section. This will single out all the different names used within the dataset. Copy and paste this pivot table anywhere on the sheet so that the names are in actual cells and not off of a pivot table. To the right of the names, enter 1 next to the first name, and then =B1+1, and so on so that you number each name with a unique value; then copy and paste this column as numbers so that their formulas are erased. Finally, just go to your original dataset and perform a VLOOKUP so that the names get attached with whatever unique value was assigned off of the pivot table. Make sure to copy and paste as numbers once done to remove the VLOOKUP formula.
Takes literally 2 minutes to do, depending on size of dataset, and is very easy. It will work perfectly every time.

How to single out unique records in the whole spreadsheet?

In EXCEL 2010 I have 2 columns which contain email addresses. I need to find those which are present in the entire spreadsheet (in both columns) only once and single them out, meaning if one record is present in column 1 and 2 then delete both records leaving only those which never appeared more than once. Any ideas ?
PREPROCESSING
Put them all in the same column. Use LOWER() if necessary to make sure they're all the same case. Use TRIM() if necessary to remove extra spaces. Sort them (not necessary with COUNTIF(), but will make spot-checking easy).
MAIN PROCESSING
Let's say your email addresses are in column A, from A2:A1000.
In cell B2, enter this formula:
COUNTIF($A$2:$A$1000,A2)
This will produce the count of each each time the email address in A2 appears in the column. Copy that down column B.
Use Excel's Filter feature to filter your list for those that have exactly 1 in column B.
=IF(COUNTIF($A:$B;A1)=1;A1;"not unique")
If your e-mail addresses are in column 1 and 2, try this formula in column 3

Resources