I have this table and I got to SUM the "Age" values when the criteria "Name=Fred" and "Source=S1".
Note that "Source" in F2 is getting everything that starts with "S1" (like a wildcard)
I also need to get the MAX from the "Age" with the same criteria. Can I use MAX with SUMPRODUCT?
=SUMPRODUCT(--(Table2[Name]=$E$2);--(ISNUMBER(SEARCH($F$2;Table2[Source])));Table2[Age])
=MAX(INDEX((Table2[Name]=$E$2)*(ISNUMBER(SEARCH($F$2;Table2[Source])))*Table2[Age];0))
Related
A B C
1 Name Last Name ID
2 Ben Dafflin ID1001
3 Yu Yiin ID1002
5 Max Gray ID1003
6 John Carl Flit ID1004
Situation 1 : Index Match with wildcards "*" (Working Fine!)
Formula : =INDEX($C:$C,MATCH("*John*",$A:$A,0))
Result : ID1004
Situation 2 : Index Match with multiple criteria (Working Fine!)
Formula : =IFERROR(INDEX(D:D,MATCH(1,(B:B="Flit")*(C:C="John Carl"),0)),"")
Result : ID1004
Problem:
In situation 2, if it only looks for cells with "Carl" or "*Carl*" it doesn't work. Any suggestion how will I use the situation 2 having an index match with multiple criteria but can still look for cells that contains such specific string.
To have your 2nd formula return a value, you just need to reference the correct columns: =IFERROR(INDEX(C:C,MATCH(1,(B:B="Flit")*(A:A="John Carl"),0)),"")
If you want to use wild cards with MATCH where you have multiple criteria, you can try:
=INDEX(C:C,MATCH(1,1/(ISNUMBER(SEARCH("*Carl*",A:A))*(B:B="Flit")),0))
If you have Office 365
=FILTER(C:C,ISNUMBER(SEARCH("*Carl*",A:A))*(B:B="Flit"))
Lookup when Matching to Multiple Columns
There's another way to approach this, which is simpler and may well be a better fit:
{=INDEX(C:C,MATCH("*CarlFlit",A:A&B:B,0))}
The above is of course an array formula (hence the opening { and closing })
a) The array matched is the rows of columns A and B concatenated into single strings
b) This specific example is of course looking for (*wild-carded) *CarlFlit
c) Which of course, could be any combination of values and valid MATCH wildcards
If the values being looked for are in cells (rather than hardcoded into the formula) simply refer to those cells:
{=INDEX(C:C,MATCH(E2&F2,A:A&B:B,0))}
To add checking for no-match (using first example above):
{=IF(ISNUMBER(MATCH("*CarlFlit",A:A&B:B,0)),INDEX(C:C,MATCH("*CarlFlit",A:A&B:B,0)),"Not Found")}
Additional information
The formula above can be expanded to accommodate matching across any number of columns.
o Simply & in each additional column (in whatever order suites your purpose).
For performance reasons, it's not a good idea to have lookup functions looking at entire columns.
a) Better to use (e.g.) {=INDEX($C$1:$C$1000,MATCH("*CarlFlit",$A$1:$A$1000&$B$1:$B$1000,0))}.
b) Where 1000 is of course an example last row in your lookup range.
I'm trying to do a Lookup formula to get get the exact value based on two fields against 3 fields (two of the lookup fields are Min and Max fields) so the idea is to get the value based on field name and another numeric field against two fields because it is a range of numbers
Lookup Table
Table where formula will be created (Inside LookupResult). See below the expected result where Price 150 for 101-A-A should be ABCD
Thanks for the help
You just need some indexing, no need for MATCH nor VLOOKUP. For example:
Formula in H2:
=INDEX(D:D,MAX(INDEX((A$2:A$3=F2)*(B$2:B$3<=G2)*(C$2:C$3>=G2)*ROW(A$2:A$3),)))
Or, if rules can really only apply to a single row:
=INDEX(D:D,SUMPRODUCT((A$2:A$3=F2)*(B$2:B$3<=G2)*(C$2:C$3>=G2)*ROW(A$2:A$3)))
I have this:
My issue:
in column F2 I want R2 -> IF -> B2+C2+D2 exists in O:O;P:P;Q:Q
but I do not know how to use VLOOKUP with multiple columns
my attemp was '=VLOOKUP(B2;O:O;4;FALSE)' and I do not know why I used 4... cuz I count R2 as index 4 from O2...
This is just a multiple column lookup. While two column lookups are more common, three column lookups are not that rare.
=index(r:r, aggregate(15, 6, row($2:$999)/((o$2:o$999=b2)*(p$2:p$999=c2)*(q$2:q$999=d2)), 1))
That will return the value from column R for the first matching set of columns O:Q. In the case of multiple matches, you could return the last match by changing 15 to 14.
Since your returned results are expected to be numeric, a sumifs could also be used.
=sumifs(r:r, o:o, b2, p:p, c2, q:q, d2)
However this would return skewed results is more than a single match was found.
In your own vlookup, the 4 represents the fourth column of your lookup range. Since you were only providing a single column (e.g. O:O), you would never return the value from column R without changing the lookup range to O:R.
Another approach (since they look like dates DD/MM/YYYY) would be to convert each group of three columns to dates
=INDEX(R:R,MATCH(DATE(D2,C2,B2),INDEX(DATE(Q:Q,P:P,O:O),0),0))
#Jeeped is right to point out that this is slow on full columns, so plz use a formula like
=INDEX(R$1:R$100,MATCH(DATE(D2,C2,B2),INDEX(DATE(Q$1:Q$100,P$1:P$100,O$1:O$100),0),0))
and adjust the ranges to include your data.
If O:O;P:P;Q:Q is unique, you can use:
=lookup(1,0/((O:O=B2)*(P:P=C2)*(Q:Q=D2), R:R)
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.
So I had a test at school where I could not solve this question, I wanted to know how it can be solved. It goes something like :
You have been given two Excel spreadsheets, one has 200 records while the other has 300. Devise a formula/method to figure out which 100 records are not present in the first file.
Could anyone tell me how this can be solved?
I could use COUNT to calculate that there are 100 records, but I need the values of the records. Is there anyway to use COUNTIF to solve this, or is there some other way?
We are allowed to import it into Access too if it cant be solved in Excel.
Edit : Example below -
Lets say the first spreadsheet has the records Q, W, E and the second spreadsheet has the records Q, W, E, R, T, Y. I need a function which returns the values : R, T, Y (as they are the values not present in the first spreadsheet)
open both files and in the bigger file, add a column with formula using some lookup function, e.g. MATCH:
=ISNUMBER(
MATCH(cell_from_this_row,
range_of_all_such_cells_from_smaller_table,
0))
filter all "FALSE" values to get the missing rows
Taking your example, you can put the formula for VLOOKUP in the longer spreadsheet (let's say the longer spreadsheet is Sheet2 and the shorter one Sheet1).
In an additional column of Sheet2 of the first record:
=VLOOKUP(A1,Sheet1!A:A,1,FALSE)
Drag and fill down for the records of Sheet2 and all the ones you don't have in Sheet1 will return #N/A. You can then filter on these #N/A to get the records not found in Sheet1.
What VLOOKUP does is that is looks for the value in A1 into the column A of Sheet1 and returns the value that matches in the column index 1. FALSE means it looks for an exact match.
Note that VLOOKUP is case insensitive.
You can still do it with COUNTIF.
This time, the formula is:
=COUNTIF(Sheet1!A:A, A1)
The formula is a little simpler and shorter to execute if you have a lot of records. It will return 0 in case it cannot find the value it's looking for in the other sheet.