Generate a 3rd column sequential number based on two columns data - excel

I apologize if the title is misleading, but
I have an issue where I need to generate a sequential number in a third column based on comparing data from two different columns.
My data looks like this:
Before
The entry with the 1 is the first point, I need to use the value in the 'Back' column to find the same value in the 'Front' Column, then add +1 to the point, so the result looks like:
After
Because of the naming conventions used, sorting either column by value will not work.
Appreciate the help!

Assuming you have the initial 1, and your number column is C, front is D, back is E, this would start at row 2:
=INDEX(C:C,MATCH(INDEX(D:D,MATCH(D2,E:E,0),1),D:D,0),1)+1
Image: http://i.imgur.com/0XfdLrk.png

Did you establish whether your data has duplicates or incomplete sequences?
Here's another formula which should achieve what you want and also doesn't rely on you knowing where the sequence starts. Every sequence will start with 1.
This formula follows your image layout, putting values into column A with data in columns B and C. Please replace the ranges in the formula for columns A and C to cover all of your data. (Ideally, you would do this by inserting a table first and then selecting the data rows, which will cause Excel to put in the table column name instead.)
This is the formula to go into cell A2, assuming you have data in B2:C7
=IF(ISERROR(MATCH(B2,$C$2:$C$7,0)),1,INDEX($A$2:$A$7,MATCH(B2,$C$2:$C$7,0))+1)
Put this formula in D2 and fill down to identify which rows are the ends of sequences:
=ISERROR(MATCH(C2,$B$2:$B$7,0))
Put this formula in E2 and fill down to identify duplicates in the Front column:
=COUNTIF(B$2:B$7,B2)
You can then fill it right one column to also identify duplicates in Back.

Related

Excel - Find all identical cells, sum separate cell in row for matches, output in other sheet

So, I've searched for an answer to this, but I can't find anything. Hopefully some Excel guru out there has an easy answer.
CONTEXT
I have a sheet that has two columns; a list of airport codes (Col A) and a list of fuel gallons (Col B). Column A has a bunch of duplicate entries, column B is always different. It's basically a giant list of fill-up events for aircraft over time at different airports. The airports can be the same, because it's one row per fill-up event.
PROBLEM
What I want to do is have a formula that takes the enter data set, finds all identical entries in Col A, sums the Col B values for the matches, and spits out the result on a separate sheet with one entry for every set/match.
OTHER STUFF
I do not have a reference list for Column A and I would rather not create one since there are thousands of entries. I would like to just write a formula that does all this at once, using the data itself as the reference.
All the answers I find are "create a reference list on a separate sheet", and it's driving me crazy!
Thanks in advance for any help!
-rt
Sounds that you need a formula version of remove duplicated for column A, and a simple sumif for column B.
Column A
=IFERROR(INDEX(Data!A$1:A$1000,SMALL(IF(
MATCH(Data!A$1:A$1000,Data!A$1:A$1000,0)=ROW(Data!A$1:A$1000),ROW(Data!A$1:A$1000)),ROW())),"")
Array Formula so please press Ctrl + Shift + Enter to complete it. After that you might see a {} outside the formula.
Column B
=SUMIF(Data!A$1:A$1000,A2,Data!B$1:B$1000)
Just change the range for your data.
Reminders: The formula in columnA should starts from Row#1, or you have to add some offset constant for adjustments.
Since the returning value of MATCH() represents the position of the key in the given array. If we wanted it to be equal to its row number, we have to add some constant if the array is not started from ROW#1. So the adjustment of data in Range(B3:B1000) is below.
=IFERROR(INDEX('Event Data'!B$3:B$1000,SMALL(IF(
MATCH('Event Data'!B$3:B$1000,
'Event Data'!B$3:B$1000,0)+2=ROW('Event Data'!B$3:B$1000),
ROW('Event Data'!B$3:B$1000)),ROW())-2),"")
Further more, the range should exactly the same as the data range. If you need it larger than the data range for future expandability, an IFERROR() should added into the formula.
=IFERROR(INDEX('Event Data'!B$3:B$1000,SMALL(IFERROR(IF(MATCH(
'Event Data'!B$3:B$1000,'Event Data'!B$3:B$1000,0)+2
=ROW('Event Data'!B$3:B$1000),
ROW('Event Data'!B$3:B$1000)),FALSE),ROW())-2),"")
Lastly, I truly recommended that you should use the Remove Duplicated built in excel since the array formula is about O(n^2) of time complexity and memory usage also. And every time you entered any data in even other cells, it will automatically re-calculate all formulas once the calculation option in your excel is automatic. This will pull down the performance.

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.

Excel: Combine =vlookup and =countif

For my question I am trying to reduce a very large amount of data using the =countif function in regards to a specific Employee ID (using =vlookup).
In Column 'A' I have every employee ID listed only once. In columns B, C, D, E, and F I would like to count every time that employee has been Hired, Promoted, received a Pay Increase, been Demoted and Fired, respectively.
In Column 'I,' I have again a list of employee ID's and in 'J' each time one of those actions were implemented.
Since there are more than 10,000 employee iterations that exist in column 'I' this is why I am trying to condense these down to numeric values in columns B:F.
ACTUAL QUESTION: Is there anyway to 'nest' these two functions in order to get the required results that I want?
Thanks in advance.
You can use Countifs with multiple conditions (not Countif, which takes only one condition)
Consider the following screenshot. The formula in cell B2 is
=COUNTIFS($I:$I,$A2,$J:$J,B$1)
Copy across and down. Note the position of the $ signs. They are important. The column references for columns I and J are absolute, and will not change when the formula is copied across. The reference to $A2 will always refer to column A, but the row will adjust when copied down. The reference to B$1 will always refer to row 1, but the column will adjust when the formula is copied across.
You can do a similar thing without any formulas at all, using a pivot table. Click a cell anywhere in the data in columns I or J, then click Insert > Pivot Table. In the pivot table pane that appears on the right, drag the Employee ID to the Rows area, drag the action to the Columns area and drag either of the fields to the Values area. The result looks like this:
Look Ma, no formulas!!

Creating dynamic dropdowns in Excel where values may appear in more than one column

Normally, where the values in the column of a lookup array are unique there is only a need to match the value in the last dynamic data validated list with the value in the relevant column of the lookup array to provide the range of values for the next dynamic data validated list. However, where values in a column are not unique, is there a way to create dynamic data validated lists in Excel? I assume that this could be achieved by ensuring the values in more than one column must have been selected in order to provide the dynamic range for the third, e.g. X must have been selected in the first drop down and Y in the second, in order to lookup the values for the third dynamic data validated list, but I can't work out how.
As an example let's say that my lookup array looks like this:
Field1,Field2,Field3
A,C,F
A,C,G
A,D,H
B,E,I
B,C,J
B,C,K
If I select B in the first dynamic data validated list and C in the second, I would want the range for the third to be J and K, not F, G, J and K.
You'd have to setup a second column for Field2 and for Field3.
If you assume your dropdowns are located in cell A10 to C10 and your fields are in column A-C then you could go over to column D and make D1 =if($a$10=a1,b1,"") and D2 would be if(countif(d$1:d1,if($a$10=a2,b2,""))=1,"",if($a$10=a2,b2,"")). You could drag D2 down for as many rows as you need. Once you do that you name that range to be Field2 (or whatever you're using as the name in your data validation list).
For Field3 you basically do the same thing except you use and. So in E1 you'd do =if(and($a$10=a1,$b$10=b1),c1,"") and E2 would be =if(countif(e$1:e1,if(and($a$10=a1,$b$10=b2),c2,""))=1,"",if(and($a$10=a1,$b$10=b2),c2,"")). When you do that, you name it Field3.
The downside is that the dropdown will have blanks and changing one of the first 2 won't reset the last ones. To overcome this pitfall you'd have to setup a worksheet change event in VBA.
EDIT:
OK start from scratch...
I'm putting the dropdowns in A12-C12 now.
You still have essentially formulas in column D and E but then you have to make 3 more columns to uniqueify (that's a technical term meaning to make unique) the previous columns. You can't see column H in this pic but it's the same template for field3. Those are array formulas so you don't hit enter after you've typed it in you hit CTRL-SHIFT-ENTER. You'll know you've done it right because it'll put curly braces around the formula. Once you make the formula copy it down.
Once you've done that then go to formulas define name.
Once there you fill out the name like this
Make sure you change the row in the countif to match your data but for the first argument of offset you just pick the first cell in the list and keep those two 0s as they are.
Once you've done that you make the dropdown based on the name from the previous step.
This should get you to about 99% of where you want to be. Unfortunately you are still susceptible to 1 blank if the first row is blank in the unique columns. I couldn't figure out how to get rid of it but since it's only 1 blank it shouldn't be too bad. Also, if you change a parent dropdown it won't reset the child dropdowns.

Excel: How to replace one of two matching columns with third

Í have two spreadsheets.
Column A has values.
Column B has the same values but in different order.
Columns C,D,F are also important and related to Column A.
I need to find the matching values from Column A and Column B.
And replace the values in Column B with the Columns C,D,F.
Thank you preliminary!
The function you are looking for is vlookup(). This function searches through a given column for the first value that matches a variable that you have set. It then steps n columns to the right and returns the value.
This function will not replace the values in column B with the desired values in C, D, & F. Rather you must create a new column and select the desired value from each column according to rules that you set.
It is unclear to me whether you wish to combine columns C, D, & F (in which case you should use the concatanate() function), or only display the values in one column based on some priority system. Concatenating the values is relatively simple, as mentioned above. Prioritizing the columns requires setting up some if / else statements to govern the condition under which each column C, D, or F will be returned.
UPDATE
Based on the image that you have appended in the comment below, I would suggest you place the following function in cell D2:
=vlookup(C2,A$2:B$8,2,0)
Then drag this equation down the length of column D, from row 2 to row 8. The references will automatically be adjusted for each row.
As a side note, I usually place the Number and Price columns into a tab of their own. If you go to the bottom left of the page you'll see that you can create a new tab (and title it whatever you like). It is important keep that information visually separate because you are using it as a lookup table. While lookup tables are important, they do not need to be visible on the main spreadsheet at all times. Plus, they almost always have a different number of rows than the data set being analyzed (in this case I'm guessing you would be analyzing Number-2 and Price-2). So it becomes awkward to display the lookup table and main data set side by side.

Resources