how to group same values into Excel array - excel

I have a duplicate value in column A with different value in column B and column C.
For example:
There are 3 column which is A, B and C.
- A has duplicate value which is serial number
- B is whether it fail the test or not
- C is the time for testing.
Is it possible with Excel to find time difference between time for first fail and pass?
I want to delete the data that have less than 12 hour so that I know the things don't need rework, just retest. I want to know the exact number of modules that need rework.

=IF(AND(B7 = "pass",B6 = "fail", A7 = A6),TEXT(C7-C6, "h:mm"), "")
To get the difference between last fail and pass use this formula in cell D7. If the cell in column B is pass and previous cell was a fail, it will work out the time difference between the previous cell that was a fail. It will also check that the cell in column A matches previous cell in column A. Can also try using Index / Match or Vlookup to get the first fail by formula. As Tim Williams said a pivot table will also help. I don't use them much, so I'm not sure how to get the time difference with a pivot table, but it'll make viewing the data easier.
You could also try adapting this formula, by nesting conditions to get the previous cell that is the first fail. Work out the maximum number of cells between a pass and a first fail, and nest it that many times. If there are cases where the fail time is later than the pass it will throw an error. If you have multiple consecutive pass cells, for the same element you'd need to add more conditions to account for that, but if there's only 1 pass per element this should work.
=IF(AND(B7="pass",B5="fail",A7=A5),TEXT(C7-C5,"h:mm"),IF(AND(B7="pass",B6="fail",A7=A6),TEXT(C7-C6,"h:mm"),""))

Related

Automate concatenation process

Here I am stucked with one excel issue where i want to concatenate from column F till column I where the logic is when the benchmark column A3 (for example) is blank it need to concatenate column F till column I till there is a value at column A4.and this logic need to automatically concatenate the mentioned column till there is a value under the benchmark column. currently i need to keep change the concatenate range in order to concatenate it fully with the logic. Appreciate if anyone can help me out.
Below image shows how i am doing manually which very time consuming
You can use the MATCH function (with a wildcard) to find the next non-blank row; and use that in an INDEX function to detect the range to concatenate.
Assuming your data starts in A3 and the lowest possible row is row 1000 (change the 1000's in the formula below if it might be much different:
J2: =IF(A2="","",CONCAT(INDEX(F2:$I$1000,1,0):INDEX(F2:$I$1000,IFERROR(MATCH("*",A3:$A$1000,0),1000-ROW()),0)))
Note: It is possible to also develop solutions using INDIRECT and/or OFFSET. Unfortunately, these functions are volatile, which means they recalculate anytime anything changes on your worksheet. If there are a number of formulas using these functions, worksheet performance will be impaired. INDEX and MATCH are non-volatile (except in ancient versions of Excel - pre-2003 or so)
The OFFSET-function would come on handy here. One solution is to do it like
This works in my worksheet.
Cell Q6 just defines the number of rows downwards that the MATCH-function is checking for the next "HEADER1" value. If "HEADER1" is found, the MATCH-function returns how many rows down-1. If no "HEADER1"-value is found within that range, that value is then the number of rows used.
If the first column also has "HEADER2" and so on, you can add the MID-function to both references inside MATCH to limit which part of the string are to be searched for.
I tried to adjust the references properly to fit your sheet, but I may have missed something:
=IF(ISBLANK($B2),"",CONCAT(OFFSET($B2,0,0,IFNA(MATCH(MID($B2,1,6),MID(OFFSET($B2,1,0,$B$1),1,6),0),$B$1),4)))

Vlookup for double values

How can i create a vlookup or VBA code such that the Vlookup function doesnt always take the first but after the first has been taken also a second value etc.
I think it becomes clearer with a screenshot
Some further explanation:
Column A is an identifier (in the real sample the cusip (an Identification number) of a company)
Column B represents a Dealnumber.
But not for every deal cusips are availble (explains empty spaces), and a company can occur in several deals(-> values in column A are not mutually exclusive)
Since the values in column A are not mutually exclusive, i have to "map" the values of column B, which are mutually exclusive, to the occurance in column D
Use this, but it requires a title row on the data column:
=IF(D1=D2,E1,INDEX(B:B,AGGREGATE(15,7,ROW($B$1:$B$6)/($A$1:$A$6=D2),COUNTIFS($D$1:D1,D2,$D$2:D2,"<>"&D2)+1)))
It does not matter what the value in D1 is but the formula must be placed in the second row as it uses the first row as a check for changes.
Since this is an array type formula the references should limit themselves to the data set and not use full column references, But we can use INDEx(MATCH()) to do that automatically:
=IF(D1=D2,E1,INDEX(B:B,AGGREGATE(15,7,ROW($B$1:INDEX(B:B,MATCH("zzz",A:A)))/($A$1:INDEX(A:A,MATCH("zzz",A:A))=D2),COUNTIFS($D$1:D1,D2,$D$2:D2,"<>"&D2)+1)))
If I am understanding how your Columns A & B are being populated (by looking at occurrences in C & D), why not just use the C&D data?
You could find the number of tasks such that (I have this in D2):
=IFERROR(IF(C2=C1,D1,D1+1),1)
This will give the occurrences without using the Vlookup or Index/Match, adding 1 where the task changes (the iferror is used to give the first "1", since you can't add "occurrence" + 1).
You probably have your answer by now. Here's a nice (additional) solution.
=IFERROR(INDEX($B$3:$B$13, SMALL(IF(D$2=$A$3:$A$13, ROW($B$3:$B$13)-2,""), ROW()-2)),"")
or
=IFERROR(INDEX($B$3:$B$13,SMALL(IF(D$2=$A$3:$A$13,ROW($A$3:$A$13)- MIN(ROW($A$3:$A$13))+1,""), ROW()-2)),"")
See this link:
https://www.ablebits.com/office-addins-blog/2017/02/22/vlookup-multiple-values-excel/
To get VBA code, enter the function and get it working, then turn on the Macro Recorder, click on the primary cell (first cell), hit F2, hit Enter to commit the change, and double click the black cross to fill down. Now, you should have all your VBA, and of course you can modify your code to do whatever you want.

Find and remove duplicate IDs and replace

I have very basic user Excel knowledge. I have a spreadsheet where I keep track of reloading data. Each load I enter gets a unique load number that is calculated automatically with a formula, based on the caliber name and an incrementally increasing number. As of now, every load I enter gets a number, even if it's been repeated before. Popular loads that I repeat often are all the same except for the date and numbers of rounds made but currently will have different load numbers. Is there a way to skips these repeated loads and assign it the previous load number or not assign a load number at all, with a formula instead of manually?
I know this is asking for a great deal but I'd greatly appreciate any help! I'm certainly open to suggestions if this isn't even the best way to go about this.
Sample workbook at:
https://www.dropbox.com/s/v5y1ufxjiosmnap/My%20Reloading%20Data%20-%20Sample.xlsx?dl=0
Here's what I've tried so far:
In column Q2, combine all the criteria.
=C17&E17&F17&G17&H17&L17&M17&N17&P17
In column R2 look for duplicates.
=IF(COUNTIF($Q$2:$Q17, $Q17)>1, "Duplicate", "")
D2 is the Load # column.
=IF(R17="Duplicate","",(TEXT(C17,0)&"-"&TEXT(COUNTIF($C$2:C17,C17),"000")))
This will skip the duplicate loads and not give them a load # leaving the cell blank. I'd love to find and match what that load # should be and insert it. Also, when the sequential numbering resumes it acts as if it's counted the duplicate row. For instance D2 might look like:
9mm-001
9mm-002
(Skipped for duplicate and left blank, but would like it to find, match, and insert the duplicate load #)
9mm-004 (I'd like to to be 9mm-003)
You should be able to achieve this with a VLOOKUP formula or a combination of MATCH and INDEX.
VLOOKUP (Vertical Lookup) looks for a match in another cell and returns a value from an offset column. A non match, if you use FALSE as the last parameter, returns a #N/A error.
So, in D20 (for example) you could, using column Q as your determinant, use the following, assuming you had a copy of D in column R:
=IFERROR(VLOOKUP(Q20,Q$1:R19,2,FALSE),[value for newly found loadno])
What this formula does is calculates a VLOOKUP - if that doesn't find a record, calculate a new value. The VLOOKUP will look at the concatenated key in the current row Q column, search through all previous columns (note it is anchored at row 1, but not anchored for the bottom of the range so you can copy the formula), it uses the column 2 (Q is column 1, so R is column 2) for the result, and demands an exact match (FALSE). If it doesn't find one, return NA and let the second half of the IFERROR take over.
See how you go with this.
The MATCH INDEX may work better because you won't need the additional R column due to VLOOKUP only being able to look to the right of the key.
Here is an INDEX and MATCH solution - slightly harder to understand, but a more flexible solution.
=IFERROR(INDEX(D$1:D19,MATCH(Q20,Q$1:Q19,0)),[value for newly found load number])
I prefer this.
The outer function says return the nth value in the list. The inner MATCH function says find this value (Q20) in this list (Q1:Q19). The 0 as the third parameter of the MATCH function says the match has to be exact.

How to use "COUNTIF" function to count one instance of something per row

I have a question I'm hoping someone in the community may be able to help me answer.
Here's my issue, I'm trying to use the COUNTIF function to determine how many times a particular value appears. Easy enough right? Here's the tricky part, I want to only count certain values from each row. Only retaining the count for a particular value from each row. Per row there should only be a max of (1) error type counted. Screenshot below for more context.
Example
Insert a helper column to track the highest priority error. In your helper column use the following formula and copy down as required. If you prefer a blank over the word none when no errors are found, change "None" to "".
=IFERROR("P"&AGGREGATE(15,6,RIGHT(E2:J2,1)/(E2:J2<>""),1),"None")
In my example below I place the helper column in column D, but it can be any column.
In D16:E16 I used the following formula and copied right
=COUNTIF($D$4:$D$13,E$15)

Is there an Excel formula with VLOOKUP in two columns

I wonder if there is a VLOOKUP formula that looks first in one column and if there is no match, proceeds to the next column and if there's still no match returns a value, for example, NO MATCH.
I've been trying to Google and YouTube the issue but couldn't find anything. Hope someone can help me here.
lets say you lookup table is is from A1:D6 with columns A and B your look up values. And the value you are looking for is in G6
start with your basic VLOOKUP function as follows:
=VLOOKUP(G6,A1:D6,3,0)
This assumes you want the value from the third column in your range (C in this case) to be returned because of the 3. You are also looking for an exact match as defined by 0.
If the value you are looking for is not found in column 1 it will produce an error. As such we can use the IFERROR function to tell us what to do when an error occurs.
=IFERROR(VLOOKUP(G6,A1:D6,3,0),VLOOKUP(G6,B1:D6,2,0))
So in the event of an error it performs the second lookup. notice the range for the look up starts in column B instead of A. Also notice that Column C is now the 2nd column in the range so the 3 changed to a 2. Now if its not found in either situation, we can simply nest the IFERROR inside another IFERROR as follows:
=IFERROR(IFERROR(VLOOKUP(G6,A1:D6,3,0),VLOOKUP(G6,B1:D6,2,0)),G6&" not found in first two columns")
This method will return the first value that matches your search criteria that it encounters starting from the top in column one and if that fails the first value from the top in column 2. It neither is found it will post an error message.
There are other ways to do this especially if there were a max of one instance of the look up value in the two columns or if you did not care about columns and just wanted the first/last row (or nth row) of the occurrence.

Resources