How to exclude 0 and blank cells when using excel MIN function - excel

Got this formula:
{=IF(A4=MIN((C4=$C$4:$C$46711)*(B4=$B$4:$B$46711)*($A$4:$A$46711)),"First Event","All")}
I'm using the same one for MAX, and it works just fine. But when changing to MIN it fails, and I suppose it's because of value 0 and/or blank cells in my range. I've tried to add "ISNUMBER" after the "IF" but it doesn't do the trick...
How can this formua be modified to return lowest value, not counting 0 and/or blank cells in Column A?

If you have this function, you can use something like the below in place of your MIN function:
=MINIFS(A1:A10,A1:A10,"<>0")
If not, something like:
=MIN(IF(A1:A10<>0,A1:A10,""))
Depending on your version of Excel, you may need to "confirm" this array-formula it by holding down ctrl + shift while hitting enter. If you do this correctly, Excel will place braces {...} around the formula as observed in the formula bar.
Substituting in your formula would look like:
=IF(A4=MIN(IF(((C4=$C$4:$C$46711)*(B4=$B$4:$B$46711)*$A$4:$A$46711)<>0,(C4=$C$4:$C$46711)*(B4=$B$4:$B$46711)*$A$4:$A$46711,"")),"First Event","All")

I test your formula for a smaller range, there can be a smaller issue, which is causing trouble to you.
In your range $A$4:$A$46711 of the formula there can be a number or entry which is "text" formatted
I have done the following three trials:
Trial 1. Try it with blanks
Trial 2. Try it with blanks and zeros too.
Result: In both the cases your formula, is working fine
Trial 3: with Text in column A, It is generating an error
Hence I am concluding to check your A column range for any text formatting

Remember you can also use Aggregate for these since Excel 2010:
=AGGREGATE(15,6,A1:A10/((A1:A10>0)*(B1:B10="a")),1)

Related

How to simplify multiple COUNTIFS in excel with non-consecutive ranges

I have a spreadsheet...
A you can see, the cell F2 has a formula with multiple COUNTSIF, basicly checks the cells F14, F33, F62 y there is a Pass there, and if there is one will give you a % completion. My question is that I have to add around 20-30 COUNTIFS to that formula, is there a way to simplify it.
=(COUNTIF(F14,"Pass")+COUNTIF(F33,"Pass")+COUNTIF(F62,"Pass")+COUNTIF(F75,"Pass")+COUNTIF(F88,"Pass")+COUNTIF(F105,"Pass"))/(COUNTIFS(F14,"<>na")+COUNTIFS(F33,"<>na")+COUNTIFS(F62,"<>na")++COUNTIFS(F75,"<>na")++COUNTIFS(F88,"<>na")+COUNTIFS(F105,"<>na"))
This is not the final formula, still missing around 20 entries. If you're wondering why not do a simple F15:FXX, because i just need the cells that have a test case name, like F14, F33, etc.
For the first part of your formula, you can use the INDEX function to return a non-contiguous set of values, which you can test.
For example, the equivalent for the first part would be:
=SUM(N(INDEX($F:$F,IF(1,N({14,33,62,75,88,105})))="Pass"))
The IF(1,N({…})) part is how you specify which cells (rows) in Column F to return.
Without knowing more about your data, not sure about handling the percentage issue.
Your posted formula would not calculate a percentage, as it is only dividing the SUM by whether or not F14<>"na" is true, and then adding one for the <>"na" factor for the rest
In earlier versions of Excel, you may need to confirm this 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.
If you want to return the percent "pass" in your list of cells, merely divide the SUM by the number of cells. You can either hard-code that number, or compute it with something like:
COLUMNS({14,33,62,75,88,105})
Or all together:
=SUM(N(INDEX($F:$F,IF(1,N({14,33,62,75,88,105})))="Pass"))/6
or
=SUM(N(INDEX($F:$F,IF(1,N({14,33,62,75,88,105})))="Pass"))/COLUMNS({14,33,62,75,88,105})

Use SUMPRODUCT when field is blank from formula and dates

I have two columns in my excel, Date 1 in A and Date 2 in B. I'm trying to find the number of times Column B is greater than Column A. I'm using the formula =SUMPRODUCT(((B2:B5-$A$2:$A$5)>0)*1) and receiving an error. The error is due to the data in Column B is being pulled in from a formula, where my value_if_false is "". While the cell is blank, Excel sees this as data and will not execute my original formula.
If I go to B4 and delete the value, my original SUMPRODUCT will execute. I'd like not have to go back and do that. I've tried =SUMPRODUCT((NOT(ISBLANK(B2:B5-$A$2:$A$5)>0))*1) but it's returning 0. Any suggestions?
Try following array formula:
{=SUMPRODUCT((IF(IFERROR(VALUE(B2:B5);FALSE); B2:B5;0)>$A$2:$A$5)*1)}
Array formula after editing is confirmed by pressing ctrl + shift + enter
Writing "" (nul string) to a cell that is supposed to contain a number (such as a date) is never a good idea because it leads to problems like this one. The solution is in not writing a string (text) to a numeric field. Write zero instead, and then deal with the display of zeros via global settings or cell formatting.
Of course, any date would be greater than zero. If this leads to the wrong count the obvious remedy would be to make a second count of instances where zero is involved and deduct the result of the second count from the first, like, SUMPRODUCT(1)-SUMPRODUCT(2)
I guess if you wanted to stick with SUMPRODUCT and avoid array entry, you could try
=SUMPRODUCT((B2:B5<>"")*(B2:B5>A2:A5))
or to exclude anything except a number (which in this case would be formatted as a date)
=SUMPRODUCT(ISNUMBER(B2:B5)*(B2:B5>A2:A5))
is possibly better.
B4 contains "", not ="".

how to count the number of #Div/0 value in excel

I wish to count the number of " #Div/0" occurrence in excel, where 1/0 results in "#Div/0" value in excel, may I know anyone has experience how to count the number of it?
Thanks.
You can use the ERROR.TYPE function.
For example, the following array-formula, will count the number of #DIV/0! errors in the range D1:D10.
=SUM(IFERROR(IF(ERROR.TYPE(D1:D10)=2,1,0),0))
An array formula must be entered by holding down ctrl + shift while hitting enter. If you do this correctly, Excel will place braces {...} around the formula seen in the formula bar.
Here is an example showing that #DIV/0, when entered as text, is not counted. Note the two changes in D9:D10. One was entered directly and became an error, the other was entered as a text string. Note also the formulas adjacent to D9:D10 indicating text vs error
Use COUNTIF. For example, if you wanted a count of #DIV/0! in the first 10 cells of column A you could use this:
=COUNTIF(A1:A10, "#DIV/0!")

How to sum several bracket-surrounded numbers of a single cell with Excel formula?

I have one cell containing several lines, including numbers inside brackets, which I want to sum-up with a single Excel formula (no VBA).
The following approach already works for single bracket:
https://exceljet.net/formula/extract-text-between-parentheses
But I need extended approach... here an example for the content of one single Excel cell to which I search for an formula, which should result in sum of "8":
The task requires following effort (incl. documentation)
- create plan (2h)
- execute test (14h)
- write report (draft) (2h)
Possible approach: The formula should search for all numbers inside the mask <"(" x "h)">, where x must be summed-up.
UPDATE: The formula should also work with numbers >=10.
UPDATE2: It should also work in case there are other comments in brackets, also after presence of first (xh) number. See "(draft)" in example, last row.
Borrow the formula from this post #6 (https://www.mrexcel.com/forum/excel-questions/362184-extracting-multiple-numbers-string.html) and modified to fit your need (single cell formula). Assuming you are going to enter the formula in cell B1:
{=SUM(VALUE(MID(0&A1,LARGE(ISNUMBER(--MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1))*ROW(INDIRECT("1:"&LEN(A1))),ROW(INDIRECT("1:"&LEN(A1))))+1,1)))}
Basically this is to assign each character with its index and then get the numeric value to sum up. Please note this is an array formula. Please click Ctrl + Shift + Enter together.
REVISED:
Here is the array formula (click Ctrl + Shift + Enter together) to extract two-digit numbers:
{=SUMPRODUCT(IFERROR(0+("0"&TRIM(MID(SUBSTITUTE(SUBSTITUTE(S‌​UBSTITUTE(LOWER(MID(‌​‌​A1,SEARCH("h)",A1)‌​-4,LEN(A1))),"h","")‌​,")","("),"(",REPT(" ",1000)),ROW(INDIRECT("1:20"))*2*1000-999,1000))),0))}
What this does is to massage the text first by removing unnecessary content, remove h wording and convert ) to 999 blanks. Then you can extract numbers and add up. IFERROR will made the anything not numbers to 0. Hope this can solve your problem.
I appreciate that this is not in any way elegant, however it is working. I do not have time to run through the logic here right now (might edit it in later though) but essentially it is a load of search index logic.
I have Used 5 columns for each formula which assumes a maximum of 5 values but you can adjust this as needed by dragging the formula over more columns as it will begin looking for the next "(?h)" after the previous column's found value.
Red cell formula: =SEARCH("(?h)",$A1)&" - "&SEARCH("h)",$A1)
Orange cell formula: =SEARCH("(?h)",$A1,MID(B1,SEARCH("- ",B1)+2,LEN(B1)-(SEARCH("- ",B1)+1))*1)&" - "&SEARCH("h)",$A1,MID(B1,SEARCH("- ",B1)+2,LEN(B1)-(SEARCH("- ",B1)+1))+1)
Yellow cell formula: =MID($A1,LEFT(B1,SEARCH(" - ",B1))+1,((MID(B1,SEARCH("- ",B1)+2,LEN(B1)-(SEARCH("- ",B1)))*1)-(LEFT(B1,SEARCH(" - ",B1))*1))-1)*1
Green cell formula: =SUMIF(G1:K1,">="&0)

numbers treated as text giving wrong values in index and sumifs

I'm indexing a table that somehow has numbers stored as text, here is a fragment:
{0\0\0\0\"110"\950\0\0\0\"3485"\0\0\0\"950"\0\0\0\0\0\100}
When I try to use sumifs for this range, i get wrong values. Is there any way to fix this in formula without changing the data?
This is the exact formula I'm using:
=SUMIFS(INDEX(INDIRECT("'"&"P_"&$C$3&"'!B9:BC100");MATCH($D6;INDIRECT("'"&"P_"&$C$3&"'!BC9:BC100");0););INDIRECT("'"&"P_"&$C$3&"'!B1:BC1");L$1))
You cannot use SUMIFS but there's a work-around.
Something like:
So if you have data like above, enter this array formula:
=SUM(IF(INDIRECT("A3:A5")=A$2,VALUE(INDIRECT("B3:B5"))))
by pressing Ctrl + Shift + Enter.
300 is entered as Text but you still get the correct total for all items equal to A$2 which is A.
Note: My local separator is , (not ; as in your example) so don't be confused.
Also, above is just an example, I'll leave the actual adaptation of your formula to you. HTH.
If you have ranges with numbers stored as text a good way to deal with this is to multiply your cells by 1 as you use them. Example below. You need to leave out the curly braces and press Ctrl+Shift+Enter to enter the formula, which tells excel to individually multiply each number by 1 before summing them (in my example)
Therefore, you might try the following formula with your data
{=SUMIFS(INDEX(INDIRECT("'"&"P_"&$C$3&"'!B9:BC100")*1;MATCH($D6;INDIRECT("'"&"P_"&$C$3&"'!BC9:BC100")*1;0););INDIRECT("'"&"P_"&$C$3&"'!B1:BC1");L$1))}
Note: I haven't tested this formula, but I did test that this method works with INDIRECT()

Resources