Find the Closest Match in Excel using data from a Table - excel

I am trying to write a formula in Excel that will find the closest match in one column and return that value, so that it can be used in a SUMIFS formula. I have done some investigating and found that everyone points at this specific formula:
{=INDEX(data,MATCH(MIN(ABS(data-value)),ABS(data-value),0))}
The issue I am having though is I am trying to convert this to use data from a Table and have this so far:
{=INDEX(_CCD01[[#All],[Date]],MATCH(MIN(ABS(_CCD01[[#All],[Date]]-TODAY())),ABS(_CCD01[[#All],[Date]]-TODAY()),0))}
But Excel returns a #VALUE! error.
What the formula needs to do, is find the closest date in column _CCD01[[#All],[Date]] using TODAY() as the search criteria.
The file with the table and formula can be found here:
Dropbox Read Only
Any help or thoughts will be appreciated.
Dave

This is an array formula.
=INDEX(_CCD01[Date],MATCH(MIN(ABS(_CCD01[Date]-TODAY())),ABS(_CCD01[Date]-TODAY()),0))
To enter/confirm an array formula, hold down ctrl + shift while hitting enter. If you do this correctly, Excel will place braces {...} around the formula seen in the formula bar.
The syntax you were using _CCD01[[#All],[Date]] will also return the header row of the column. There's no need for this, and it is the cause of your #VALUE! error.
The ABS function will return a #VALUE error (as the first element) in the array it returns when applied against the column since the first entry is text.
And then MIN arguments that are error values or text that cannot be translated into numbers cause errors.

Related

IFERROR not returning an array and thus breaking the SUMPRODUCT result

I have a column in a spreadsheet in which numbers are sometimes
stored in text format or are mixed with text values.
For converting them to numbers I would
normally use VALUE. And because of the other text values in the same column I would additionally wrap it
with IFERROR, defaulting the result to 0 to prevent any issues with the
conversion.
All this I wanted to use in SUMPRODUCT and I am reluctant to add any new intermediate columns to the sheet.
I face an issue with IFERROR returning a single value (or even a #VALUE! error) when it is used in SUMPRODUCT as one of the arrays. What's even worse, the sum is correctly assessed in the Function Arguments window.
I created an isolated case, that you can see here SUMPRODUCT using IFERROR problem. One of the numbers in column C is preceded with with single quotation "'" and the C column holds both text and number values.
A long version of the SUMPRODUCT formula
=SUMPRODUCT(IFERROR(VALUE($C1:$C4),0),--($D1:$D4="yes"),--NOT(ISERROR($C$1:$C$4+1-1)),--(($C1:$C4)<>"")) and the simplified one =SUMPRODUCT(IFERROR(VALUE(C19:C21),0)). It returns a correct number in the Function Arguments window when in the spreadsheet it shows #VALUE! error or respectively an incorrect sum.
I wonder if I am using the aforementioned functions wrong (can't IFERROR be used as an array here?), or is this some sort of an Excel bug (why the assessed value is different from the result in the spreadsheet?).
Thanks in advance for your comments and suggesting a solution.
Your formula :
=SUMPRODUCT(IFERROR(VALUE($C1:$C4),0),--($D1:$D4="yes"),--NOT(ISERROR($C$1:$C$4+1-1)),--(($C1:$C4)<>""))
and
=SUMPRODUCT(IFERROR(VALUE(C19:C21),0))
all need to be confirmed with Ctrl+Shift+Enter
Another option,
Change your formula into :
=SUMPRODUCT(N(+$C1:$C4),--($D1:$D4="yes"),--NOT(ISERROR($C$1:$C$4+1-1)),--(($C1:$C4)<>""))
and
=SUMPRODUCT(N(+C19:C21))
the change using N(+.... instead of IFERROR(VALUE(....
also, the above 2 formulas need not array entry

How to find the first value in a column larger than the previous value in the column

I'm looking for an excel formula to return the index of the first value in a large column such that ABS((COL)(ROW)-(COL)(ROW+2))< 0.1
Clearly, this is pretty easy to program in VBA by starting with the first row in the column and iterating through. However, I'm just looking for an excel formula in this case.
I think it will need to be something functionally like:
=INDEX($A$1:$A$100,MATCH(TRUE,($A$1:$A$100)-($A$3:$A$102)<.1,0))
This clearly won't return anything. I'm interested in how to do that subtraction part using excel formulas.
Thanks!
Just need to add the ABS and ARRAY ENTER the formula:
=INDEX($A$1:$A$100,MATCH(TRUE,ABS(($A$1:$A$100)-($A$3:$A$102))<.1,0))
Being an array formula it must be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode. If done correctly then Excel will put {} around the formula.

Create a List using Index, Match, and Concatenate

I have a formula in Excel, which is almost working. However, there is a part of the formula which no matter, what I try and do I can't seem to get it to work.
Working Formula
=IFERROR(INDEX(DDRT!$K$7:$K$158,SMALL(IF(DDRT!$K$7:$K$158<>"",MATCH(ROW(DDRT!$K$7:$K$158),ROW(DDRT!$K$7:$K$158)),""),ROW(A1))),"")
This formula will create a list and ignore any blanks in the Array K7 to K158, which is exactly what I am trying to do, however, it is the Value K that is a variable and is based on a list in another sheet.
I have a concatenate which returns the correct value based on the list, which works fine.
Concatenate Formula
=CONCATENATE("DDRT!",ADDRESS(List!$E$6,MATCH(Transmittal!$D$3,DDRT!$A$6:$L$6,0)),":",ADDRESS(List!$E$7,MATCH(Transmittal!$D$3,DDRT!$A$6:$L$6,0)))
Value Returned - DDRT!$K$7:$K$158
When I try and combine the two formulas together, the array doesn't work and returns an error:
Non-working formula
=IFERROR(INDEX(CONCATENATE("DDRT!",ADDRESS(List!$E$6,MATCH(Transmittal!$D$3,DDRT!$A$6:$L$6,0)),":",ADDRESS(List!$E$7,MATCH(Transmittal!$D$3,DDRT!$A$6:$L$6,0))),SMALL(IF(CONCATENATE("DDRT!",ADDRESS(List!$E$6,MATCH(Transmittal!$D$3,DDRT!$A$6:$L$6,0)),":",ADDRESS(List!$E$7,MATCH(Transmittal!$D$3,DDRT!$A$6:$L$6,0)))<>"",MATCH(ROW(CONCATENATE("DDRT!",ADDRESS(List!$E$6,MATCH(Transmittal!$D$3,DDRT!$A$6:$L$6,0)),":",ADDRESS(List!$E$7,MATCH(Transmittal!$D$3,DDRT!$A$6:$L$6,0)))),ROW(CONCATENATE("DDRT!",ADDRESS(List!$E$6,MATCH(Transmittal!$D$3,DDRT!$A$6:$L$6,0)),":",ADDRESS(List!$E$7,MATCH(Transmittal!$D$3,DDRT!$A$6:$L$6,0))))),""),ROW(A1))),"")
Image of Returned Error Message
=IFERROR(INDEX(INDIRECT(CONCATENATE(ADDRESS($E$6,MATCH($D$3,$A$6:$L$6,0)),":",ADDRESS($E$7,MATCH($D$3,$A$6:$L$6,0)))),SMALL(IF(INDIRECT(CONCATENATE(ADDRESS($E$6,MATCH($D$3,$A$6:$L$6,0)),":",ADDRESS($E$7,MATCH($D$3,$A$6:$L$6,0))))<>"",MATCH(ROW(INDIRECT(CONCATENATE(ADDRESS($E$6,MATCH($D$3,$A$6:$L$6,0)),":",ADDRESS($E$7,MATCH($D$3,$A$6:$L$6,0))))),ROW(INDIRECT(CONCATENATE(ADDRESS($E$6,MATCH($D$3,$A$6:$L$6,0)),":",ADDRESS($E$7,MATCH($D$3,$A$6:$L$6,0)))))),""),ROW(A1))),"")
That is your formula with indirect in it. I had to remove sheet names so I could enter it in excel. It does not have your error message. All I did was wrap your concatenate formula in an indirect formula.
=INDIRECT(CONCATENATE("DDRT!",ADDRESS(List!$E$6,MATCH(Transmittal!$D$3,DDRT!$A$6:$L$6,0)),":",ADDRESS(List!$E$7,MATCH(Transmittal!$D$3,DDRT!$A$6:$L$6,0))))

Excel: Sumproduct not working when blanks in data set

I am trying to get a sumproduct function to average a column based on criteria in prior adjacent columns.
The column i am trying to average is calculated from a formula that has an IFERROR to return a blank if there is an error.
=IFERROR(A5*B3,"")
some of the cells in that column containt the blank generated by the if error statement, my sumproduct is giving a #value error when it tries to average the range with the blank. I want it treated as nothing not as 0
Is there anyway around this or should I try to recreate my sumproduct using some sort of averageifs function?
This is the sumproduct in question:
=SUMPRODUCT((Data!$KM$7:$OV$7=C$7)*(Data!$KM$9:$OV$118>=$B10)*(Data!$KM$9:$OV$118<=$A10)*(Data!$BLW$9:$BLW$118))/SUMPRODUCT((Data!$KM$7:$OV$7=C$7)*(Data!$KM$9:$OV$118>=$B10)*(Data!$KM$9:$OV$118<=$A10))
Try this array formula instead:
=AVERAGE(IF((Data!$KM$7:$OV$7=C$7)*(Data!$KM$9:$OV$118>=$B10)*(Data!$KM$9:$OV$118<=$A10)*(Data!$BLW$9:$BLW$118<>""),Data!$BLW$9:$BLW$118))
Being an array it needs to be confirmed with Ctrl-Shift-Enter when leaving edit mode. If done properly excel will put {} around the formula.
The reason SUMPRODUCT will not work is it tries to multiply a string, albeit an empty string but a string none the less, with numbers, which will throw an error.
The array formula ignores all the empty string cells and skips them.
The formula =IFERROR(A5*B3,"") puts a "" in the cell. This is not a value, so formulas using this cell won't work. You need to turn it to a numeric value even though it is blank
Use =value(IFERROR(A5*B3,""))
=SUMPRODUCT(P10,M10,L14,L13). This could be easy. We have to write what we want to do rather it is sum, product, division or subtract

Excel 2013: Using the Search()-function through a table column?

I'm trying to search through a table column and use the Search()-function to find out if any of the words in the column appear in a given cell.
As you can see here, the formula returns FALSE, even though "Chicken" is in the list. If I move "Chicken" to the top in the column, it will return true. This leads me to believe that the formula only looks at the first item in the column.
Upon entering the formula, I used the CTRL+SHIFT+ENTER keys to make sure it's an array formula.
Does anyone know why it doesn't look through each of the rows in the column?
Edit: I guess the formula stops when it gets any value (even if that value is false)? Maybe there is a function for searching until true?
Try this non CSE formula:
=IF(SUMPRODUCT((ISNUMBER(SEARCH(Table1[Search words],A1)))*1)>0,TRUE,FALSE)
The reason is that without Sum() or Sumproduct, it is only returning the first iteration.

Resources