I'm trying to compare values across two columns (Product and Location) in Excel to highlight duplicates, but I can't figure out the logical test. I'm looking for rows that match three criteria:
Product value is duplicate
Product value is not blank
Duplicate 'Product' values occur with different 'Location' values
(Products with the same value in the same location are assumed to be distinct for a value I don't have, but products with the same name at different locations may be duplicate).
Edit: I want the formula to evaluate to true only if the same Product occurs in more than one Location.
I can figure out the first two conditions by themselves, but can't figure out how to incorporate the third. I've sorted the table so that the duplicate values should appear next to each other, but there are too many to check by eye.
I'm currently using this logical test for conditional formatting using the first two criteria. 'Product' occurs in column C, 'Location' occurs in column I.
=AND(C1<>"",COUNTIF($C:$C,C1)>1)
Given your criteria, I think what you need would be the CountIfs function for the 3rd criteria....
Your final formula would look as follows:
=AND($C1<>"",COUNTIF($C:$C,$C1)>1, COUNTIFS($C:$C,$C1,$I:$I,"<>" & $I1)>0)
In effect, your third criteria is saying Count if the product matches C1 AND the Location does NOT equal I1
Hope that does the trick!
NOTE:
The more I think about it, the more I'm pretty sure you do not need your second criteria... I've been trying to think of an example where your second criteria would affect the result of this final outcome, but can't find one....
Just something to consider....
It might be overkill, but how comfortable are you with PivotTables?
Insert a pivot table, and put the "Product" in the row, with the data as the "count" of Location.
Then add a column with a formula similar to:
=GETPIVOTDATA("Location", <top left cell of pivottable> ,"Product", <cell that has product you want a count of>)
The "Location" and "Product" text would have to match your column titles.
The easiest way to get the forumla right is to type "=" in the cell you want to have the value in, and then click on the pivot table cell that contains the value. You then replace the static text, with the cell that has the value you want to look up.
Related
The blue columns is the data given and the red columns is what is being calculated. Then the table to the right is what I am referencing. So, F2 will be calculated by the following steps:
Look at the Machinery column (D), if the cell contains LF, select column K, otherwise select column L
Look at the Grade column (E), if the cell contains RG, select rows 4:8, otherwise select rows 9:12.
Look at the Species column (A), if the cell contains MS, select rows 5 and 10, otherwise.......
Where every the most selected cell is in columns K and L, copy into column F.
Multiply column F by column C.
I don't want to make another column for my final result. I did in the picture to show the two steps separately. So column F should be the final answer (F2 = 107.33). The reference table can be formatted differently as well.
At first, I tried using nested-if statements, but realized that I would have like 20+ if statements for all the different outcomes. I think I would want to use the SEARCH function to find weather of not the cell contains a specific piece of information. Then I would probably use some sort of combination of match, if, v-lookup, index, search, but I am not sure how to condense these.
Any suggestion?
SUMPRODUCT is the function you need. I quickly created some test data on the lines of what you shared like this:
Then I entered the below formula in cell F2
=SUMPRODUCT(($I$4:$I$9=E2)*($J$4:$J$9=LEFT(A2,FIND(" ",A2)-1))*IF(ISERROR(FIND("LF",D2,1)),$L$4:$L$9,$K$4:$K$9))
The formula may look a little scary but is indeed very simple as each sub formula checks for a condition that you would want to evaluate. So, for example,
($I$4:$I$9=E2)
is looking for rows that match GRADE of the current row in range $I$4:$I$9 and so on. The * ensures that the arrays thus returned are multiplied and only the value where all conditions are true remains.
Since some of your conditions require looking for partial content like in Species and Machine, I have used Left and Find functions within Sumproduct
This formula simply returns the value from either column K or L based on the matching conditions and you may easily extend it or add more conditions.
I have a spreadsheet with thousands of rows and numerous columns. What I am hoping to accomplish is to basically check column AB for a certain value. When it finds a row that contains (not exact match, just needs to include) the word "test" then I want to check if column Z (in the same row) has value "next". If both those are true, then I want to display the value from column N in that same row. What code could I use to accomplish this?
Note: I need this to list the value from column N for each row that has both "test" and "next", not just for one row.
Edit:
To clarify what I mean by multiple values see this image:
I want a formula that will list ALL of the Column N values of rows that meet have both test and next. And this list is not in the row, it is going to be one column listing each match.
Update:
I have gotten close to getting this done, this is my best formula up to this point. =ArrayFormula(IF(ISNUMBER(MATCH("*"&$A$1&"*",SID!AB:AB,0)),SID!N3,"n")) This works once, but here is what I need fixed:
This returns the first value that works, in this example Place1, but then it just lists everything form column C, even if it does not reach the requirements. Most likely an issue with my arrayformula.
Try out the below formula,
=IF(AND(ISNUMBER(MATCH("*"&"test"&"*",A1,0)),ISNUMBER(MATCH("*"&"next"&"*",B1,0))),"Column N value","")
This formula searches cell A1 for the string test (anywhere in it) and searches next in cell B1. I leave the part of replacing the cells with the required columns to you and also change the Column N value in the formula to N1
I am trying to lookup a table in one of my sheets. my table consists of three columns and an unlimited amount of rows.
My table can be seen here:
In my second sheet I wish to write a formula which searches all rows in the table and looks for an exact match in column A and column B, this means it must find the row where column a has a value of "jan" and in that same row the second column must have value "y". Should it find this match, it should return the value of column C.
I tried researching hlookup but that is for horizontal tables so i dont believe this would work. I looked into Vlookups also but that only allows one criteria search instead of looking for two matches.
Can anyone shed some light here please?
You can use index and match with multiple criteria
=INDEX($A$1:$C$1000, MATCH("Jan"&"y", $A$1:$A$1000&$B$1:$B$1000, 0),3)
press CTRL + SHIFT + ENTER when entering this formula.
Convert the range to a table (ctrl-t) and then use SUMIFS to search the table based on two criteria
=SUMIFS(Table1[Alteration],Table1[Month],"Jan",Table1[Products],"y")
This is saying "give me [Alteration] where [Month] = "Jan" and [Products] = 'y'...this returns 364.
You can point the criteria at separate cells containing your criteria.
Be aware that if there is more than one row with identical data (ie more than one row with both 'Jan' and 'y'), column C will be summed together.
The INDEX function has the syntax
INDEX(array, row_num_in_array, [column_num_in_array])
And MATCH returns in the index location of a logic match
MATCH(lookup_value, lookup_array, [match_type])
Combining the two is a flexible technique, and surprisingly powerful -- the logic in a match lookup_value can be a complex condition.
SIMPLEST CODE
Operate on the whole column
INDEX(C:C, MATCH("Jan"&"y", A:A&B:B, 0), 1)
nb./ A:A is excel code for "all of column A". You can instead use:
RESTRICTED CODE
Operates on a subset of the sheet.
INDEX($C$2:$C$1000, MATCH("Jan"&"y", $A$2:$A$1000&$B$2:$B$1000, 0), 1)
Note that you MUST use identical row length arrays (eg. rows 2:1000) or the formula will not work. MATCH only knows how many rows into its lookup_array it got, you need to ensure its rows match those in INDEX's array
PS. apologies this is close to the previous answer, but the details were too long for a comment.
PPS. I missed the clarifications to the first answer. That will work, but there is no need to use all three columns as the array in the INDEX function. You are only returning data from column C after all.
I have a data source in the format as the one below. In reality, that would contain few thousand rows.
I need to use something like INDEX-MATCH-MATCH in order to be able to get the "Status" for each "Content" item for each UserID.
The final result should look like this. The first two columns are not dynamic.
The INDEX formula goes to C and D.
I am using the following sequence to try and write the formula, but I don't seem to understand where the problem is.
=INDEX(Sheet1!A:K, [Vertical Position], [Horizontal Position])
look up the user with ID xxx:
=INDEX(Sheet1!A:K, MATCH(A2, Sheet1!A:K,0), [Horizontal Position])
look up the status for eLearn1.
=INDEX(Sheet1!A:K, MATCH(A2, Sheet1!A:K,0), MATCH("Status", Sheet1!A:K,0))
What am I doing wrong?
The question is not clear, but I think you are trying to do a LOOKUP based on the values of two columns. So for a particular value of Column A (UserID) and Column B (Content) you need to return Column H (Status).
This can be done using an array formula to return the row number of the matching line which can be fed into INDEX. Note, that this will only work as long as Columns A&B only have unique pairings.
I have set up some sample data:
Columns A-C are my source data. Cells G2:H4 are the lookup.
The formula is:
=INDEX($C$1:$C$7, SUM(($A$1:$A$7=$F2)* ($B$1:$B$7=G$1)*ROW($C$1:$C$7)))
This needs to be entered as an array formula by pressing CTRL-ALT-ENTER.
The formula works by matching the value you are searching for in both arrays and multiplying out the results. This should give you a result array consisting of all False with one True indicating the matched row. This is then multiplied against the row number to return the correct row to the INDEX formula.
I have a large Excel dump from SQL with many columns of data. Two of those columns have different fields with various text values. There are six correct values for the first column and five correct values for the second column. I need to count the accounts (column A) that have both "correct" values.
Well, I just stumbled on this guy:
=COUNTIFS(A:A,"val1",B:B,"val2")
where:
A:A is the first column you have.
"Val1" is the valid value in the first column you want.
B:B is the 2nd column you have.
"Val2" is the valid value in the 2nd column you want.
Unfortunately, that only works if you have 1 value for each column .. and they work more like an AND .. not an OR.
So rather than that, I'd suggest a "helper column":
1) setup your list of valid values somewhere else, and name the lists: "validcol1" and "validcol2"
==IF(OR(ISERROR(MATCH(A2,validcol1,0)),ISERROR(MATCH(B2,validcol2,0))), "", "Valid!")
I solved it through and array that uses "find."
{ =SUM(1*(IFERROR(FIND(b1:b413,"0B,D,E,K,L,S"),0)>0)*(IFERROR(FIND(c1:c413,"0ZA,ZB,ZC,ZF,ZK"),0)>1))}
Note the use of the leading 0 at the start of each set of values.
It's my understanding hard-coding the values into the formula isn't ideal. Anyone have any ideas for that?