Excel: Sumproduct not working when blanks in data set - excel

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

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 get length of FORMULATEXT() in SUMPRODUCT()?

I need to count all cells with a certain length of FORMULATEXT(), I decided to go for SUMPRODUCT() as I believe you can't count by length while using COUNTIF(). The formula that I use while counting cells of certain length is this one:
=SUMPRODUCT(--(LEN(AV3:AV201)<>7))
Adding the FORMULATEXT() function resulted in error.
VBA is unfortunately out of question as our accounting system can't recognise .xlsm files.
Try this array formula with CSE,
=SUMPRODUCT(--(IFERROR(LEN(FORMULATEXT(AV3:AV201)), 7)<>7))
If FORMULATEXT sees text, numbers or a blank cell, it returns #N/A. IFERROR can return those as LEN 7 so they are not included in the count.
Without compensating for errors, your formula will only work if AV3:AV201 contains a formula in each cell.

COUNTIFS function not working with single cell range

I'm having an issue with COUNTIFS function in excel, i have a very large formula that I was getting an error on, but I have slowly taken the formula apart to a smaller subset and identified the issue I'm having. Excel won't use COUNTIFS correctly when the criteria range is one cell. Here's the formula I'm using:
=COUNTIFS(A7:A7,1,Sheet1!F:F,$A$9,Sheet2!S:S,$B$8)
Whenever I take the first criteria out "A7:A7,1" my formula returns a value, without it I receive #VALUE! error. Can you not use one cell as the criteria for CountIFS? I've also tried replacing "A7:A7" with just "A7" or "$A$7". The first criteria is the most important, because i'm going to be using a listbox for that cell that will change the values in my range for interactive graphs..
The ranges in the countifs need to be the same size.
Wrap the COUNTIFS() in a IF:
=IF(A7=1,COUNTIFS(Sheet1!F:F,$A$9,Sheet2!S:S,$B$8),0)

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))))

Formula returns #VALUE! when entered as array

I've put together an Excel spreadsheet to keep track of employees' time off using an array formula. The formula works for date ranges that are entered as "mm/dd - mm/dd", but I'd like it to also support single dates "mm/dd". However, I get a #VALUE! error when one of the cells in the range is of this format, even though the formula supports both formats when not entered as an array formula.
Example:
With the value "11/28" in cell B2, and a table of holidays in B31:B37, the following formula accurately calculates the number of work days as 1.
=SUM(IF(ISBLANK(B2),0,(IF(ISERR(FIND("-",B2)),NETWORKDAYS(B2,B2,$B$31:$B$37),NETWORKDAYS(LEFT(B2,5),MID(B2,FIND("- ",B2)+2,5),$B$31:$B$37)))))
If the value of B2 is "11/28 - 12/03", the formula returns 4.
I want this formula to work over a range of of cells for each employee, so I expand the range from "B2" to "B2:B10", and enter as the following array formula:
=SUM(IF(ISBLANK(B2:B10),0,(IF(ISERR(FIND("-",B2:B10)),NETWORKDAYS(B2:B10,B2:B10,$B$31:$B$37),NETWORKDAYS(LEFT(B2:B10,5),MID(B2:B10,FIND("- ",B2:B10)+2,5),$B$31:$B$37)))))
This formula works fine when every cell in the range is blank or has a date range of "mm/dd - mm/dd". However, if one of the cells has a single date "mm/dd", it throws a #VALUE! error.
What am I missing?
If there is no "-" in a given string then the FIND function will return a #VALUE! error for that string.
In general, there are two ways to resolve such issues. One is to include an error trap; the other, slightly longer though perhaps nevertheless preferable (IFERROR clauses are generally best avoided if possible), is to make suitable amendments to the strings being passed to MID and FIND such that this combination of functions does not error, whilst also ensuring that correct results are returned.
One such solution (still array-entered) is:
=SUM(IF(B2:B10<>"",NETWORKDAYS(LEFT(B2:B10,5),MID(B2:B10&"- "&B2:B10,FIND("- ",B2:B10&"- ")+2,5),$B$31:$B$37)))
Regards

Resources