I need to be able to find the row number of the row where matching criteria from A1 is equal or greater than values in column C and lesser or equal than values in column D
I can use INDEX and MATCH combo but not sure if this is something I should use for multiple criteria matching.
Any help or suggestions are highly appreciated.
I would not use MATCH to get the row number since you have multiple criteria. I would still use INDEX however to get the value of the row in E once the proper row number was discovered.
So instead of MATCH I would use an array formula using an IF statement that contained multiple criteria. Now note that array formulas need to be entered using ctrl + shift + enter. The IF statement would look like this:
=IF((A1>=C:C)*(A1<=D:D),ROW(A:A),"")
Note: I did not use the AND formula here because that cannot take in arrays. But since booleans are just 1's or 0's in Excel, multiplying the criteria works just fine.
This now gives us an array containing only blanks and valid row numbers. Such that if rows 5 and 7 were both valid the array would look like:
{"","","","",5,"",7,"",...}
Now if we encapsulate that IF statement with a SMALL we can get whatever valid row we want. In this case since we just want the first valid row we can use:
=SMALL(IF((A1>=C:C)*(A1<=D:D),ROW(A:A),""),1)
Which if the first valid row is 5 then that will return 5. Incrementing the K value of the SMALL formula will allow you to grab the 2nd, 3rd, etc valid row.
Now of course since we have the row number a simple INDEX will get us the value in column E:
=INDEX(E:E,SMALL(IF((A1>=C:C)*(A1<=D:D),ROW(A:A),""),1))
If you need to match more than one column value to retrieve a row number, that is, if two or more columns together create a unique ID you can use an array formula with MATCH as below:
MATCH(1,(A:A=J1)*(B:B=K1)*(C:C=L1),0)
where A, B, C contain the column array to be matched to retrieve the unique row number corresponding to the value in J1, K1, L1 respectively.
For a step-by-step guide, Christian Pedersen's Explainer
Related
Main table contains names and number of appearance.
I need new list of names where every name will be repeated as many times as value in number of appearance cell.
Assuming your "MAIN LIST" is in A2:C7 (including headers), try the following array formula
=IFERROR(FILTERXML("<t><s>"&TEXTJOIN("",TRUE,REPT($B$3:$B$7&"</s><s>",$C$3:$C$7))&"</s></t>","//s"),"")
Note: Clever idea from answer by #VafāSarmast here
Using JvdV's solution for this Find row number of sum result in range
Assuming your names are in column B and appearance in column C, use the following:
=INDEX(B$1:B$7,MATCH(TRUE,--SUBTOTAL(9,OFFSET(C$1:C$7,,,ROW(C$1:C$7)))>=ROWS($1:1);0)
Enter as array formula (ctrl + shift + enter).
It returns the row number of the sum of values in column C that equals the number of rows used in your results list and shows the value in that row from column A.
I have a dataset looking at ratings over time:
A B C D E
ID Date Rating-1 Rating-2 Rating-3
1 01/01/20 Y
2 01/05/19 Y
3 15/12/19 Y
I want to extract the rating for a particular ID at a particular date. As the rating is not specified in the data (as each is represented by a Y value), I need to reference either the column heading or the column reference.
To get the relevant row, I can use a Match formula:
=MATCH(1,(1=$A$1:$A$4)*(DATE(2020,01,01)=$B$1:$B$4),0) - this will give row 2.
To get the column reference for a specific row, I can use a second Match formula: =MATCH("Y",$A3:$E3,0) - this will give column 4.
Is there a way to combine the two formulas to give me the column reference for a specified row (based on ID/Date criteria) and a specified column (the column with a Y value)?
I have tried a Index Match Match formula, but this seems to require the column reference to be specified, rather than finding a column with a Y value.
Try to avoid INDIRECT as it's volatile! There are other options such as below:
=INDEX(A1:E1,MATCH("Y",INDEX(A1:E4,MATCH(1,INDEX((A1:A4=1)*(B1:B4=DATE(2,020,1,1)),),0),0),0))
BTW, the nested INDEX is there to avoid necessity to CSE the formula. If you have ExcelO365 this could be removed.
Found a solution using INDIRECT, CONCATENATE and MATCH:
{=MATCH("Y",INDIRECT(CONCATENATE("$A",MATCH(1,(1=$A$1:$A$4)*(DATE(2020,01,01)=$B$1:$B$4),0),":$E",MATCH(1,(1=$A$1:$A$4)*(DATE(2020,01,01)=$B$1:$B$4),0))),0)}
Effectively, the CONCATENATE and INDIRECT parts of the formula creates a range specified by ID and Date criteria. This range takes the form of a single row in which to the MATCH function then searches for the Y value and returns the column number.
I would like to know how to use a combination of Index/Match to pull data from one column to another by referencing multiple criteria. From the image attached, Column R should be auto populated (with a formula) with values from column A based on its corresponding reference in Column S.
Column S will match with Row 1 to find its column location in the array B2:K11. In the matched column, excel should then find the Row number that contains any value equal to or greater than 0 (or not blank). When it finds the row with a value it will pull the value from column A into Column R.
For example, in R2, it will look at S2 and see it needs the location for X1. It will go to the array and find X1 in B1. It will go down the column and find a value in B3 since the "10" is there. It will pull A3 into R2.
Im trying to do this without using VBA and as clean and efficiently as possible (i.e if possible without helper columns, and less processing power required). I have provided an example image of what I am trying to accomplish as I am unable to upload the actual file.
I have tried a variety of Index/Match combinations but have been unable to modify the array not to be fixed to a specific column. I have also tried ADDRESS() to create a custom array but this did not work, Attempted formulas are shown below:
In R2 to find column location: =MATCH(S2,A1:K1)
To Find Row number in B2:B11 (single column):
{=MATCH(TRUE,ISNUMBER(B2:B11),0}
{=MATCH(TRUE,B2:B11>=0,0)}
=MATCH((LOOKUP(2,1/(B$2:B$11<>""),B$2:B$11)),B$2:B$11,0)
I need to combine these, but the array of the column to look in should be addressed to the column which was matched.
To Index column A:
=INDEX($A:$A,ROW,0)
Overall:
=INDEX(A:A,(=MATCH((LOOKUP(2,1/(COLUMN NUMBER MATCHED<>""),COLUMN NUMBER MATCHED)),COLUMN NUMBER MATCHED,0)),0)
If the values in your Array are all numeric, you can use:
R2: =LOOKUP(9.9+307,INDEX($B:$K,0,MATCH(S2,$B$1:$K$1,0)),$A:$A)
If the values might be numeric or alpha, then try:
R2: =LOOKUP(2,1/LEN(INDEX($B:$K,0,MATCH(S2,$B$1:$K$1,0))),$A:$A)
In each case, the formula will match the last entry in the particular X labelled column.
Column "A" is a numbering column for each Row, some numbers are the same, ie..
A1 is 1
A2 is 3
A3 is 1
A4 is 3
I need a formula that will show how many cells with content are in this column without counting duplicates, as above would be 2. I was figuring an "If-Then" formula but am unable to get it straight. Any help out there? Thank you in advance!
If you're using Excel 2013, I want to say that there's a count distinct function. Nonetheless, you can do it like this:
=SUM(IF(FREQUENCY(A1:A4,A1:A4)>0,1))
EDIT: Adding an explanation. The FREQUENCY function gets the frequency of the unique values within the array A1:A4 (first parameter), binning it using the values within A1:A4 (second parameter). The IF checks to see if that returns anything, i.e. if the frequency is greater than 0, in which case it returns 1 for each unique value it finds. Then the SUM adds the number of 1s returned by the IF statement, in turn giving you the number of unique values within the array A1:A4.
Imagine a 100x100 table. I have to find a given value in the first column. Then I have to check the row contains that given value, and I have to find the column where the value is 1 (every row has only one cell with value 1), and I need the first row's value of that column. I've tried several lookup functions (vlookup, hlookup, index match match, etc). No results. Is it possible using only functions and no VBA at all?
I'd prefer to use INDEX rather than INDIRECT, it's not volatile and it's more robust in dealing with added rows or columns than "hardcoded" values like "B" and "D", so assuming data in A1:Z100 you can use this formula for the match, assuming a search value of "x"
=MATCH(1,INDEX(B2:Z100,MATCH("x",A2:A100,0),0),0)
...and you can add an extra INDEX function to retrieve the first row value for that column
=INDEX(B1:Z1,MATCH(1,INDEX(B2:Z100,MATCH("x",A2:A100,0),0),0))