Use INDEX(MATCH) to find value based on multiple criteria - excel

I am using INDEX(MATCH) to look up a value in one column using criteria from two different cells in another sheet. Here is the formula I am trying to use:
=INDEX(Sheet1!P:P,MATCH(1,(Sheet1!A:A=Sheet2!C$1)*(Sheet1!B:B=Sheet2!$B2),0))
Sheet1 is the array and column P contains the values I am wanting the formula to return. Column A in Sheet1 contains the values for the first criteria and Column B in Sheet1 contains the values for the second criteria. The criteria are represented in C1 and B2 of Sheet2. This will change as the cell is copied. Can anyone see any errors in this formula? It is returning a "value is not available for the formula or function."

This will have to be entered as an array formula¹ so the full column references should be cut down to a minimum size or you will experience unnecessary calculation lag as hundreds of thousands of blank cells are processed.
With text in column A,
=index(Sheet1!$P$1:index(Sheet1!$P:$P, match("zzz", Sheet1!$A:$A)),
match(1, (Sheet1!$A$1:index(Sheet1!$A:$A, match("zzz", Sheet1!$A:$A))=Sheet2!C$1)*
(Sheet1!$B$1:index(Sheet1!$B:$B, match("zzz", Sheet1!$A:$A))=Sheet2!$B2), 0))
With numbers or dates in column A,
=index(Sheet1!$P$1:index(Sheet1!$P:$P, match(1e99, Sheet1!$A:$A)),
match(1, (Sheet1!$A$1:index(Sheet1!$A:$A, match(1e99, Sheet1!$A:$A))=Sheet2!C$1)*
(Sheet1!$B$1:index(Sheet1!$B:$B, match(1e99, Sheet1!$A:$A))=Sheet2!$B2), 0))
You did not have absolute reference anchors (e.g. $ ) in the original Sheet1 range references but the way you had them set up for the criteria from Sheet2 led me to believe that you required them for both row and column.
If you have column header labels in row 1, change A1, B1 and P1 to A2, B2 and P2.
¹ Array formulas need to be finalized with Ctrl+Shift+Enter↵. If entered correctly, Excel with wrap the formula in braces (e.g. { and }). You do not type the braces in yourself. Once entered into the first cell correctly, they can be filled or copied down or right just like any other formula. Try and reduce your full-column references to ranges more closely representing the extents of your actual data. Array formulas chew up calculation cycles logarithmically so it is good practise to narrow the referenced ranges to a minimum. See Guidelines and examples of array formulas for more information.

Related

Reference data from a range on one sheet to individual cells on another based on neighboring cell value (Excel 365)

Sheet 1 will be references to individuals based on unique identifiers, such that column A will be their name and column B will have the identifier.
Sheet 2 will be an imported list of all individuals in our data set, such that column A is their name and column B is the identifier.
The goal is to be able to fill cells in Sheet 1 Column A based off of values entered in Sheet 1 Column B, by referring to Sheet 2 Column B., i.e. if the column B values match between sheets, I want the neighboring value in Column A to be copied over.
I'm a novice at this, but I don't think CONCATENATE is what I'm looking for, so the closest I've gotten is:
=IF($B:$B=Sheet2!$B:$B,Sheet2!$A:$A)
which results in a SPILL error, because I think my formula is trying to display multiple reference cells of data in one destination cell, whereas a formula such as
=IF(B3=Sheet2!B3, Sheet2!A3)
returns expected results, but is too limited for my purposes, in that it would be potentially faster to just manually enter the data, at that rate.
Trying to simplify, I'll have a sheet that has say 100 people in it, with identifiers 1 through 100. If I punch in their identifier in a separate sheet, I'm looking for their name to be displayed in a neighboring cell, or at least to have their name returned in the same cell, i.e. I enter "90" in Sheet1A1 or Sheet1B1 and it gives me "John Doe" in A1, which is the value of Sheet2B90 that's associated with the number "90" that is in Sheet2A90.
So VLOOKUP does work with some wrangling, but XLOOKUP was the ultimate solution to what I needed. A formula such as
=XLOOKUP(A13,$A$1:$A$10,$B$1:$C$10,NONE)
Would return data from B1 through B10 and C1 through C10 to elsewhere in the sheet, in this case next to a lookup cell A13 into cells B13 and C13, if the value in A13 appears within the lookup array of A1 through A10. Locking the cells with $ allows the formula to be dragged down a range of lookup cells without Excel incrementing the values of the lookup or return arrays, just the value of the lookup cell.

FInd nearest value within list condition

I want to find nearest value of a cell but don't know how.
In my excel sheet cell B1 has a value(LIST NAME) and cell B2 has other value which is to be searched with condition. If cell B1 has value GP_42(list name) then search the value of cell B2 withing list GP_42 (D4:D13) If cell B1 has value GP_42(list name) then se[![enter image description here][2]][2]arch the value of cell B2 withing list GP_42 (E4:E13). If value doesn't match then result should be the nearest matched value. Result should be display in the cell B3.
I'll assume you want the closest value. This means that you need the absolute (ABS function) of the difference between the value in GP_42 and your search value.
In B3 as an array formula¹,
=INDEX(GP_42, AGGREGATE(15, 6, ROW(GP_42)/(ABS(GP_42-B$2)=MIN(ABS(GP_42-B$2))), ROW(1:1))-ROW(GP_42)+1)
I have used ROW(1:1) to represent the number 1. This gives you the first encountered match. In my expanded examples, the third has two matches that meet the 'minimum difference' in B9 and B10. B10 is achieved by filling down. This advances ROW(1:1) to ROW(2:2) which represents 2 and gives you the second available match.
¹ Array formulas need to be finalized with Ctrl+Shift+Enter↵. If entered correctly, Excel with wrap the formula in braces (e.g. { and }). You do not type the braces in yourself. Once entered into the first cell correctly, they can be filled or copied down or right just like any other formula. Try and reduce your full-column references to ranges more closely representing the extents of your actual data. Array formulas chew up calculation cycles logarithmically so it is good practise to narrow the referenced ranges to a minimum. See Guidelines and examples of array formulas for more information.

If value in Column A matches value in Column B then return ALL matches in Column C

So I have three columns I'm working with.
The first is a list of category IDs.
The second and third are category ID matched with unique user IDs.
I'm trying to say if the value in Column A matches the value in Column B, then return the value of every instance in Column C. VLOOKUP only returns the first value where there's a match, and I'm trying to return all values where there's a match.Thanks for any help!
Try this array formula in Cell D5 and drag to the right and down:
={INDEX($C:$C, SMALL(IF($A$1=$B:$B, ROW($B:$B)-MIN(ROW($B:$B))+1, ""), COLUMN(A1)))}
It will give all matches for the value in Cell A1 in a horizontal list.
Array formulas need to be finalized with Ctrl+Shift+Enter↵. If entered correctly, Excel with wrap the formula in braces (e.g. { and }). You do not type the braces in yourself. Once entered into the first cell correctly, they can be filled or copied down or right just like any other formula. Try and reduce your full-column references to ranges more closely representing the extents of your actual data. Array formulas chew up calculation cycles logarithmically so it is good practise to narrow the referenced ranges to a minimum. See Guidelines and examples of array formulas for more information.

Skipping Rows with certain value in formula

iam trying to create a COLUMN using array from another sheet of same workbook that omit cell with empty value like shown in column C which is I required
column A Column B Column C
A 15 A
B 10 B
C BLANK D
D 7 F
E BLANK
F 11
I tried this code for got error #NUM
=IFERROR(INDEX('DATE WISE CONSUMPTION'!B$30:B$87,SMALL(IF('DATE WISE CONSUMPTION'!G$30:G$87<>"",ROW('DATE WISE CONSUMPTION'!B$30:B$87)-ROW('DATE WISE CONSUMPTION'!B$30)+1),ROWS(D$30:D31))),"")
A 'list-unique-with-conditions' array formula requires a single cell above the first cell with the formula in order to avoid circular references.
In an unused cell to the right as an array formula¹,
=IFERROR(INDEX('DATE WISE CONSUMPTION'!B$30:B$87, MATCH(0, IF(LEN('DATE WISE CONSUMPTION'!G$30:G$87), COUNTIF('DATE WISE CONSUMPTION'!J$29:J29, 'DATE WISE CONSUMPTION'!B$30:B$87&""), 1), 0)), "")
Fill down as necessary.
        
Your formula would have worked as an array formula finalized with CSE and this slight modification,
=IFERROR(INDEX('DATE WISE CONSUMPTION'!B$30:B$87,SMALL(IF('DATE WISE CONSUMPTION'!G$30:G$87<>"",ROW('DATE WISE CONSUMPTION'!B$30:B$87)-ROW('DATE WISE CONSUMPTION'!B$30)+1),ROW(1:1))),"")
You were starting off with ROWS(D$30:D31) which resolves to 2 not 1 so the SMALL function was returning the second match to start off with, not the first.
¹ Array formulas need to be finalized with Ctrl+Shift+Enter↵. If entered correctly, Excel with wrap the formula in braces (e.g. { and }). You do not type the braces in yourself. Once entered into the first cell correctly, they can be filled or copied down or right just like any other formula. Try and reduce your full-column references to ranges more closely representing the extents of your actual data. Array formulas chew up calculation cycles logarithmically so it is good practise to narrow the referenced ranges to a minimum. See Guidelines and examples of array formulas for more information.

Series based on row and column combination

I have an Excel with rows and columns as below:
I need to build a series like below in Excel with two columns as shown:
I have a huge data set where rows are dates and columns are data in half hours.
Which would be the best method?
I would suggest using the INDIRECT function thus:
In the column when you want to have the Row labels, put this formula:
=INDIRECT("R" & MOD(ROW()-1, COUNTA(A:A))+2 & "C1",FALSE)
Here A:A refers to the column where your row labels are stored and +2 is offset to the first row with a label.
In the column where you want the Column labels, put:
=INDIRECT("R1C" & ROUNDDOWN((ROW()-1)/COUNTA($B$1:$D$1),0)+2,FALSE)
Here $B$1:$D$1 refers to the range with your column labels, and +2 is again offset to the first column label.
Assuming your data is in the range C7:F12
We’ll need three fields to show the resulting series: Row, Col and Data
Row: in cell H7 enter this formula and copy till the last record:
=IF(EXACT(H6,H$6),1,
IF(EXACT($I7,CHAR(133)),"",
IF($I7=1,SUM(1,H6),H6)))
Col: in cell I7 enter this formula and copy till the last record:
=IF(EXACT(I6,I$6),1,
IF(EXACT(I6,CHAR(133)),CHAR(133),
IF(I6=COLUMNS($C$7:$F$12),
IF(H6=ROWS($C$7:$F$12),CHAR(133),1),
SUM(1,I6))))
Data: in cell J7 enter this formula and copy till the last record:
=IF(EXACT($I7,CHAR(133)),"",
INDEX($C$7:$F$12,$H7,$I7))
The following will produce your results but the array formula will impact calculation lag depending upon the number of rows and column of data in the original data matrix.
    
The array formula¹ in A10 is,
=IFERROR(INDEX(A$2:A$6, MATCH(0, IF(COUNTIF(A$9:A9, A$2:A$6&"")<COUNT($1:$1), 0, 1), 0)), "")
The standard formula in B10 is,
=IF(LEN(A10), INDEX($B$1:INDEX($1:$1, MATCH(1E+99,$1:$1 )), , COUNTIF(A$10:A10, A10)), "")
Data retrieval in C10 is accomplished with,
=INDEX(A:J,MATCH(A10,A:A,0),MATCH(B10,$1:$1,0))
Fill down as necessary.
¹ Array formulas need to be finalized with Ctrl+Shift+Enter↵. Once entered into the first cell correctly, they can be filled or copied down or right just like any other formula. Try and reduce full-column references to ranges more closely representing the extents of your actual data. Array formulas chew up calculation cycles logarithmically so it is good practise to narrow the referenced ranges to a minimum. See Guidelines and examples of array formulas for more information.
Posting a revised answer following sample data provided by user (left prior answer as it might be useful to other users)
Assuming your data is in the range C6:K11
We’ll need four fields to show the resulting series: Row, Col, 'DateandTime`
Row: in cell M7 enter this formula and copy till the last record:
=IF(EXACT(M6,M$6),1,
IF(EXACT($N7,CHAR(133)),"",
IF($N7=1,SUM(1,M6),M6)))
Col: in cell N7 enter this formula and copy till the last record:
=IF(EXACT(N6,N$6),1,
IF(EXACT(N6,CHAR(133)),CHAR(133),
IF(N6=COLUMNS($C$6:$K$6),
IF(M6=ROWS($B$7:$B$11),CHAR(133),1),
SUM(1,N6))))
Date: in cell O7 enter this formula and copy till the last record:
=IF(EXACT($N7,CHAR(133)),"",
INDEX($B$7:$B$11,$M7,0))
Time: in cell P7 enter this formula and copy till the last record:
=IF(EXACT($N7,CHAR(133)),"",
INDEX($C$6:$K$6,0,$N7))
Fields Row and Col can be hidden

Resources