So I've been asked to make a 'skills matrix' using excel and seem to be struggling with the logic somewhat. I have created a dropdown list (x,y,z), each of the options refers to a different dataset. For example, if I were to select 'x' from the list I would like to return data, using vlookup, specifically from the relevant table. The intention is to create a form which will return people and skills based on the initial selection.
I'm currently using
=IF(ISERROR(SEARCH("x",$B$1)),"",VLOOKUP(P13:$P$16,$P$2:$S$16,1)) which works ok if I select 'x'.
So basically I'm looking for something which will work like:
If x then vlookup from table x, elif 'y' then vlookup from y, else z
If anyone can help me I'd be much obliged.
What I would do is the following, with a single search of a single value as I am not 100% sure I got what you want to achieve :
Use the name manager to build a name for each of your data range to search through (X Y and Z) and give them a convenient name, for example X_Range, Y_Range, Z_Range
Type in cell B1 the range to search (X, Y or Z)
Type in cell B2 the value to look for
Use the following formula to search cell B2 in the proper range you indicate in B1
=VLOOKUP(B2;INDIRECT(B1 & "_Range");2;FALSE)
INDIRECT is the key. It will allow you to resolve the string that is build with the range name and the literal "_Range" as a range name...
Hope that helps
Related
I am trying to write a formula working like an index match to obtain cost in column AB.
The idea here is I would like the formula to go through all three parameters like in a logic tree. Note: the parameters are varying in my different files so i would like to avoid any hardcoded names like (IF x = "CV" or "CH", otherwise "*").
Example:
Q1, what is the Parameter 1? I have a choice between AAA, BBB, CCC and *. I want BBB. Because BBB is listed, proceed with BBB.
Q2, what is the Parameter 2? I have a choice between CH, CP, CU and *. I want CV. Because CV is not listed, proceed with *.
Q3, what is the Parameter 3? I have a choice... (see above)
Q4, what is the Parameter 4? If my product name (column X) contains this value in its name, go for it. Otherwise, go for *.
Q5, what is the Parameter 5? If my product name... (see above)
I hope i explained it clearly. If not, there is a screenshot to show what i meant.
In essence, I tried something like
{ = index(x,match(1,(p1),(p2),(p3)...),0)}
with some nested if formulas but unfortunately i could not make it.
Suppose you have the following named ranges:
Col_P1 being data range of Parameter 1;
Col_P2 being data range of Parameter 2;
Col_P3 being data range of Parameter 3;
Col_P4 being data range of Parameter 4;
Col_P5 being data range of Parameter 5;
Col_Cost being data range of all costs;
The formula you put in Cell L2 is:
{=SUMPRODUCT(IF((Col_P1=I2),(Col_P1=I2),(Col_P1="*"))*IF((Col_P2=J2),(Col_P2=J2),(Col_P2="*"))*IF((Col_P3=K2),(Col_P3=K2),(Col_P3="*"))*IF(ISNUMBER(FIND(Col_P4,H2)),ISNUMBER(FIND(Col_P4,H2)),(Col_P4="*"))*IF(ISNUMBER(FIND(Col_P5,H2)),ISNUMBER(FIND(Col_P5,H2)),(Col_P5="*"))*Col_Cost)}
It's an array formula which needs to be confirmed by pressing
Ctrl+Shift+Enter in the formula bar.
The logic is to use IF function to compare each parameter within the relevant range, and then multiply the matched result with the corresponding cost and add them up.
So here is the potential problem, if your criteria is returning multiple matches, the cost will be the total of all matches.
The aftermath depends on your preference. If for multiple matches you would like to return an average cost, you can divide result from the above formula by the result from the following array formula:
{=SUMPRODUCT(IF((Col_P1=I2),(Col_P1=I2),(Col_P1="*"))*IF((Col_P2=J2),(Col_P2=J2),(Col_P2="*"))*IF((Col_P3=K2),(Col_P3=K2),(Col_P3="*"))*IF(ISNUMBER(FIND(Col_P4,H2)),ISNUMBER(FIND(Col_P4,H2)),(Col_P4="*"))*IF(ISNUMBER(FIND(Col_P5,H2)),ISNUMBER(FIND(Col_P5,H2)),(Col_P5="*")))}
which is 90% the same as the first formula but without the last array Col_Cost.
If you want to return the smallest or largest match from multiple matches, please update your post so I can rewrite my solution accordingly.
Cheers :)
I need to count the number of cells in which the cells in "LIST A" appear in the set of values contained in column D AND the cells in "LIST B" do not appear in column E.
I am trying to use something like the following array formula, but so far have had limited success:
={SUM(COUNTIFS(A2:A21,D2:D5,B2:B21,"<>"&E2:E3))}
Please note that the data contained in this example is different to the data in my real table. The real table is considerably longer and more complex than this table.
Any suggestions?
just for your example the formula like in my comment will be enough
=SUMPRODUCT(COUNTIF(D2:D5,A2:A21)*NOT(COUNTIF(E2:E5,B2:B21)))
the problem ocures if you have multiple values you want to exclude. then you need to use a negative countif(s)
=SUMPRODUCT(1*NOT(COUNTIF(E2:E5,B2:B21)))
this would count all lines which contain anything of the exclude list. But the NOT inside the sumproduct will switch it to opposite (the 1* is needed cus it would only contain bool which can't be count)
if you have column C with bool (true/false or 1/0) you can simply add that:
=SUMPRODUCT(COUNTIF(D2:D5,A2:A21)*NOT(COUNTIF(E2:E5,B2:B21))*C2:C21)
or also (C2:C21>12) if that is what you need... but you also could include it to the include list (if A is A/B/E/F and C is (2/4/6)
=SUMPRODUCT(COUNTIFS(D2:D5,A2:A21,F2:F5,C2:C21)*NOT(COUNTIF(E2:E5,B2:B21)))
But every exclude needs its own countif (B is not X/Y and C is not 8/9/11)
=SUMPRODUCT(COUNTIFS(D2:D5,A2:A21)*NOT(COUNTIF(E2:E5,B2:B21))*NOT(COUNTIF(F2:F5,C2:C21))
As already said: Having formulas which return "" may return false counts (keep that in mind)
Best to switch to SUMPRODUCT in such cases:
=SUMPRODUCT(0+ISNUMBER(MATCH(A2:A21,D2:D5,0)),1-ISNUMBER(MATCH(B2:B21,E2:E5,0)))
Regards
I have a sheet with the following demo data (yeah the content is german don't mind that)
And I need a formula which will search for the criteria in A1 and B1 and returns the respective value out of the matrix E3:M8
For example
Search criteria is: X and 2 - Return value should be wert2
or
Search criteria is: Z and 1 - Return value should be wert7
I think I can somehow use an INDEX formula but not quite sure how to do so..
Hope you can help
It looks as if your data has merged cells. If you want to keep life simple, avoid merged cells.
Your data has the same 1,2,3 sequence in each section x, y and z. I assume that these values will always be the same. With the data laid out like in your screenshot, the formula you need is
=INDEX($E$3:$M$7,MATCH(B1,$E$3:$E$7,0),MATCH(A1,$E$3:$M$3,0)+2)
Because of the merged cells it is impossible to select the range in column E for the first Match function. It needs to by typed instead. You also need to adjust the second Match result for the column, since the x, y, and z are stored in the first of the merged three cells, but you want the value underneath the third of the merged cells. Avoid merged cells.
A better data layout would be this:
The Index/Match could be simplified to
=INDEX($E$3:$H$7,MATCH(B1,$E$3:$E$7,0),MATCH(A1,$E$3:$H$3,0))
Or you could use Vlookup
=VLOOKUP(B1,$E$3:$H$7,MATCH(A1,$E$3:$H$3,0),FALSE)
Hi All,
I have a table for employee scores levels (Table D1 to F6), there is points for each level, for example score (4.60) will be in the 3rd level which has (3) points.
I want to write a formula in the column (B) to check in the table an return the point value from the column F, You can see the examples in D2 & D3.
Regards
Adel
What you need is one of the most awesome functions ever invented... VLOOKUP
=VLOOKUP(A2,$D$2:$F$6,3, TRUE)
(Paste in B2 and drag down)
Quick explanation of the arguments.
A2 is the value we're going to be looking up in the table
$D$2:$F$6 is the "table" we're going to be looking up. It's going to search the first column of it (You could have anything you wanted in Column D, VLOOKUP Only looks at the first column).
3 is the column number of our table that contains the answers we want to be looking up, and returning (in this case, F).
TRUE means we want to search ranges, not just exact values. If it was FALSE then we'd only get the numbers we wanted if we entered the precise scores.
Of course, using this method, there isn't any upper bounds to it, a value of say 20 would give us the last row (i.e. 5 points), however, you could fix this easily using an IF statement.
=IF(A2 > $E$6, "N/A", VLOOKUP(A2,$D$2:$F$6,3, TRUE))
This could of course be done a bit neater if you believed you were going to be adding more rows to the table later, but it works for now.
Use the Below formula in cell B2:
=VLOOKUP(A2,$D$2:$F$6,3, TRUE)
is there a way to combine a search formula with a lookup or possibly use an if then statement. I think I have the first part working but need help with the second part. I am looking for values in column A and based on the values found in column A, I need to look at values in other columns and return the value found in that column.
Example, if column A contains value "car", I need to look at column B and return the value found in column B in column F , if column A contain value "boat", I need to look at column C and return the value found in column C in column F.
Any help would be much appreciated
Assuming that you have a list of possible values: car, boat, bike, plane, ... that would lead you to look for values in column B, C, D, E, ... I suggest you do the following:
Define the name "transportation" (whatever name you want to call it) with the types of transportation you need - for example, ={"car", "bike", "tram", "bus", "boat"} . On Office for Mac 2011 you do this with Insert->Name->Define... - for other versions of Excel it might be different (but note - you actually type both the = sign and the {} curly braces around the list of values you want to be able to look up). Put them in the order of the columns that you want.
For every lookup that you need, you can now write
=INDEX(B4:F4,0,MATCH(A4,transportation,0))
if the value (car, bus etc) is in cell A4, and you want to look up the corresponding value from columns B through F.
If you have column headings above your columns, you can use the MATCH function without having to define a name explicitly. For example, if you have car, bike, tram etc in cells B1:F1, you can use
=INDEX(B4:F4, 0, MATCH(A4, $B$1:$F$1, 0))
to do the lookup.
Explanation: the MATCH function (with third parameter 0) looks for the exact match for the first value (in cell A4 in this case) in the array that is the second parameter (either the named range, or the range with fixed address that I gave above). You then look up the appropriate cell using the INDEX function which gives you an offset into the range (B4:B4 in the above) of cells where you need to do the lookup.
I trust you can adapt this to your exact needs. Ask if you need more help.
The following formula is the simplest way I can think to do it:
In cell F1, the formula would be
=IF(A1="car",B1,C1)
This is case insensitive, so it should work for CAR as well. But bear in mind that this has the downside that with a formula this simple, ANY value in A1 other than "car" (not just "boat") would lead to the other value ending up in the F column.
=IF(A1="car",B1,IF(A1="boat",C1,""))