Lookup using multiple columns and values - excel

I have a sheet filled with data like below:
Gender MS Age Value
Male Married 21 1
22 2
23 3
24 4
Male Single 21 5
22 6
23 7
24 8
Female Married 21 9
22 10
23 11
24 12
Now there's this other sheet where the user will only be inputting the column "Gender", "MS", and "Age" values and the excel formula should be fetching the associated factor. Please help me with one such formula.
For e.g. If the user puts Male, Single and 23, the formula should return 7.

Here is an example on your sample data:
Formula in G4:
=INDEX(D1:D13,MATCH(1,(ROW(C1:C13)>=MATCH(1,(A1:A13=G1)*(B1:B13=G2),0))*(C1:C13=G3),0))
Enter through CtrlShiftEnter

You can use an array formula for this. I am assuming the blank data under Gender and MS are filled in.
=INDEX(Sheet1!A:D,MATCH(1,(Sheet2!A2=Sheet1!A:A)*(Sheet2!B2=Sheet1!B:B)*(Sheet2!C2=Sheet1!C:C),0),4)
After entering the formula, don't press enter! It is Ctrl+Shift+Enter to make this an array formula.
The formula given compares the values in cells A2, B2 and C2 of Sheet2 with the data held in columns A to D of Sheet1, and outputs the value of the fourth column of the appropriate row.

Related

FILTER function on column containing numbers, text and empty cells

0
A
B
C
1
Year
From
1974
2
2004
To
2005
3
2016
Result
3
4
1996
5
6
no info
7
1974
8
no info
9
10
11
12
In Cell C3 I want to count the rows in Column A where the year is
a) >= the value in Cell C1 AND
b) <= the value in Cell C2
Therefore, I implemented this formula:
=ROWS(FILTER($A$2:$A$12,($A$2:$A$12>=C1))*($A$2:$A$12<=C2))
However, this formula returns 11 as result which is probably caused by the empty cells and the no info input in Column A.
To avoid that those inputs are considered in the count of the rows I tried to go with this:
=ROWS(FILTER($A$2:$A$12,($A$2:$A$12>=C1))*($A$2:$A$12<=C2)*($A$2:$A$12<>"")*($A$2:$A$12<>"no info"))
However, this formula still returns 11 as result.
How do I have to modify it to get the correct values?
What about COUNTIFS()? Try-
=COUNTIFS(A:A,">="&C1,A:A,"<="&C2)
and with FILTER() try-
=ROWS(FILTER($A$2:$A$12,($A$2:$A$12>=C1)*($A$2:$A$12<=C2)))
You've put double close brackets )) too early in your formula, ending the Filter() function and then putting additional conditions outside of it.
Change the formula to
=ROWS(FILTER($A$2:$A$12,($A$2:$A$12>=C1)*($A$2:$A$12<=C2)*($A$2:$A$12<>"")*($A$2:$A$12<>"no info")))

Index match returning N/A when lookup value is null

I have a summary sheet in a workbook that allows a user to enter in a 3 digit ID and some summary data and a chart populates. In the source data, the ID for the totals row is blank. So, when the lookup value is blank (no 3 digit ID is entered) I expected the Index Match formula to return the values corresponding to a blank cell in the lookup array, but it doesn't. How can I fix this?
Sampling of the data:
ID March April
111 10 15
222 15 10
333 10 10
35 35
Formula used:
=INDEX(B9:B12,MATCH(A1,A9:A12,0))
Where A1 is the lookup value
Say we have data like:
and we want to enter the name in A1 and retrieve the age in B1 and also accommodate the blank in column E.
In B1 enter:
=IF(A1="",INDEX(F:F,MATCH(TRUE,INDEX(ISBLANK(E1:E30),0,0),0)),VLOOKUP(A1,E2:F21,2,FALSE))
You cannot lookup a blank cell. Use IFERROR to find the first blank with AGGREGATE in the target if you receive an #N/A.
=INDEX(B9:B12, iferror(MATCH(A1,A9:A12,0), aggregate(15, 6, row($1:$4)/not(len(A9:A12)), 1)))
row($1:$4) is the position within B9:B12 that you are returning to the INDEX.

Extract numbers from excel table

I have a Excel table with 5 columns filled with numbers, for e.g.
A1 B1 C1 D1 E1
4 12 23 37 41
1 4 19 25 45
4 20 25 31 44
I want to find the exact place (ROW,COLUMN) for each number.
In K1:
=COUNTIF($A$1:$E$3,H1)
where for e.g. H1=4 the result is 3
In (L1,M1,N1):
=SMALL(IF($A$1:$E$3=$H$1,ROW($A$1:$E$3)-ROW($A$1)+1),COLUMNS($L1:L1))
with Ctrl-Shift-Enter and the result is L1=1,M1=2,N1=3
Now I want to find a formula which show me the COLUMN number. If I use in (L2,M2,N2)
=SMALL(IF($A$1:$E$3=$H$1,COLUMN($A$1:$E$3)-COLUMN($A$1)+1),COLUMNS($L2:L2))
with Ctrl-Shift-Enter I have as result L2=1,M2=1,N2=2 which is not that I want. The order must be L2=1,M2=2,N2=1.
I have stuck with this. I use office 2007.
You could use the results you got from the rows to get the columns maybe?
=MATCH($H$1,INDEX($A$1:$E$3,L1,0),0)
In L2, filled through to M2 gives you the results you are expecting. Note that this formula works only if the number you're looking for (here 4) appears only once in any given row.

vlook up for multi combination value

Friend.
I have sheet1 like below
Jan Feb Mar Apr
A 10 15 13 10
B 11 11 15 12
C 12 13 15 14
D 12 10 10 15
In Sheet 2! i have 2 scroll scroll down list in cells made by data validation.fist one is in A1 with the values A, B and C, in A2 cell with the values Jan,Feb,Mar.
What i need on this, if i select A and Jan from scroll down list. i need to show the value as '10' in A3 Cell
I tried VLook up with my limited knowlege but i can provide only one value in Lookup value and array.
Please help.
You have to provide vlookup a number of column to return as variable, which you may get as a return value of match function.
Sheet1 has populated range A1:E5, where first row contains names of months (range A1:E1). Sheet2 has only values in two cells A1 and A2.
You need to find in which column of Sheet1 is a month, that is done by
match(a2, Sheet1!A1:E1, 0)+1
and find the value with VLOOKUP.
The final formula would be
=vlookup(a1, sheet1!a1:e10, match(a2, sheet1!A1:e1, 0)+1, false)
EDIT: The first time I messed Sheet1 and Sheet2.

Excel table : how can I change row and column?

I have a table excel with one column and X rows.
4 various informations
example:
row 1 2 3 4 = informations for 1
row 5 6 7 8 = information for 2
I would like to know how can I do to have these information by row instead of by column?
Example:
paul
madrid
14
victor
canada
23
emilie
paris
18
and I Would like:
paul Victor Emilie
Madrid Canada Paris
14 23 18
If you want change data only once, use Copy/Paste
Switch (transpose) columns and rows
Or if you want use formula
TRANSPOSE function
Or you can use the INDIRECT function instead. It's a bit tricky but it works :
On the same sheet where you have :
Paul
Madrid
23
Victor
Montréal
22
Aude
Copenhague
17
Valérie
Alger
28
Add something like (for example on columns B, C, D) :
1 2 3
4 5 6
7 8 9
10 11 12
etc.
It's easy to do with =X+3 formula and drag down formula.
Then, this matrix represent the position of each element in the list, you now just have to use INDIRECT in this way :
=INDIRECT("A" & B1)
A is the column where are your data
B1 is the position of the first element in the matrix
By draging this formula down and on the right, you will the matrix with the A's elements.
(Using example where source column in G2:G100 and target table in H2:J34.)
Type formula below in first cell of target table (H2):
=OFFSET($G$2;(ROW()-ROW($2:$2))*3+COLUMN()-COLUMN($H:$H);0)
Replacing $G$2 with first cell of source data, $2:$2 with first row of target table and $H:$H with first column of target table (mind the $).
Then just drag formula left and then bottom.

Resources