I have a list of 1000's of unique identifiers (locations), each with a value attached. EG:
LOCATION_A 10
LOCATION_B 3
LOCATION_C 6
LOCATION_D 12
LOCATION_E 6
etc
I want to create a rule whereby once a value for a location has been used, that location can no longer be used in further calculations.
At the moment I use VLOOKUP to return the values. I suppose I could instead create a calculation row by row (for each location), but with thousands to get through this doesn't seem appropriate.
Related
I am attempting to return a value a specific value in excel if there is a date overlap between two different rows. There is a requirement that another cell matches, this would be an ID but only return the value for a second ID also listed.
I have a report where column 1 is the name ID, column 2 is the project id and column 3 and 4 are the start and end dates.
If there is an overlap of dates based on name ID, I want excel to return the project id from column 2 of the row that is committing the overlap.
Example of desired outcome
I'm not sure there's an easy way to do this in Excel*, but it would be fairly straightforward in SQL - is that an option? If it is, you need an ID column - just a simple incremented integer.
Also, you need to specify what happens if there is more than one other overlapping entry.
unless you like writing complex functions and/or navigating Excel's rather tortuous SQL option.
I am trying to determine the average of values in a column based upon a column with a unique identifier. I have included a picture for clarification.
Column A represents block groups, of which there are 27 unique groups. Column E represents the year a structure was built within that block group. There are multiple instances of the same block group number in Column A and I would like to aggregate each of these block group numbers and determine the average year built for all of the structures in each of the 27 block groups.
For example, there are 18 cases of block group '240419601001' and my goal is to average the years associated with this block group number and then have that result appear in a new column.
My end goal is to take these averages and use them to fill in rows where there is no year built associated with a specific block group.
Thanks.
You want AverageIf():
=AVERAGEIF(A:A,"240419601001",E:E)
so in an empty column put this formula in row 2:
=IF(E2="",AVERAGEIF(A:A,A2,E:E),E2)
Then copy and past just the values over column E.
I have a worksheet with colums of names and amounts. The names are in (C2:C33,J2:J33,Q2:Q33,X2:X33). The amounts are in (G2:G33,N2:N33,U2:U33,AB2:AB33).
What I'm trying to do is find the highest 8 amounts, with the coresponding name. Meaning, for example - the name in C3 corresponds to the amount in G3, the name in J3 corresponds to the amount in N3, etc.
Using:
=LARGE((G2:G33,N2:N33,U2:U33,AB2:AB33),1)
I am able to find the top 8 values (by changing the 1 to 2, 3, 4, etc.). I couldn't figure out how to 'bring along' the name with that, so I kept searching. I found an explanation that gave me this:
=INDEX($C$2:$C$33,MATCH(1,INDEX(($G$2:$G$33=LARGE($G$2:$G$33,ROWS(N$36:N36)))*(COUNTIF(N$36:N36,$C$2:$C$33)=0),),0))
Copied down 8 cells will give me the names of the highest 8 combinations, but only from that first grouping of column C using column G values.
I've been searching for how to do this for the past few weeks, and I've run out of ideas. I don't know if I can modify the first formula to also grab the names, or the second formula to go across the other 3 corresponding groups. Once I get the top 8 names and amounts on the first sheet, I need to compare those to the top 8 on more than 100 other sheets to get the top 8 overall.
Does that make sense, and is it even possible? Do I need to use VBA? I'm running Excel 2010, but I don't know if the solution will be version specific. A thousand thanks if someone can figure this one out for me!
Not completely sure what you are asking for but here is a set of normal excel code that will provide you with the first instance of the highest value and return it's corresponding cell.
=INDEX(C2:C33,MATCH(MAX(G2:G33),G2:G33,0),1)
If you are asking for the 8 highest values in that column... you would use
=INDEX(C2:C33,MATCH(LARGE(G2:G33,[replace with 1-8]),G2:G33,0),1)
Edit: Of course it won't work if there are two numbers with the same value. In that case I would use VBA, pull the numbers into a 2D array and reorder the array based on the values in column G.
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
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.