Is there any if function to skip NA values in excel - excel

Hi All, I am trying to use average function where it can skip the NA values. As per attached snapshot how can i get the result of correct one which is 200/3. I want to take the count of NA but not while calculating average. I can's use 0 because the value will be calculated as well like the sAMPLE2 snapshot. Please advise.

AGGREGATE is able to do this:
=AGGREGATE(1,4,your_range)
1 is to activate the AVERAGE function;
4 is to ignore error values.

There are different functions which can do that: there is =IfNA() and there is =IfError() worksheet functions.
You can use worksheet functions in VBA, using Application.WorkSheetFunction object, like Application.WorksheetFunction.IfNA() or Application.WorksheetFunction.IfError().
More information can be found in the IFNA documentation or the IFERROR documentation.
Good luck

You can use combination of SumIf <> # NA and CountA function as both have ability to ignore errors.
SUMIF(D2:D4,"<>#N/A")/COUNTA(D2:D4)
This would help

Related

In Excel how can I use IF Function with more then 70 conditions or is there any other way to do that

I'm trying to add if function with more then 70+ conditions. How can I do that or is there any other way to do that? I'm sharing screenshot.
Please help.
You have the tendency to nest IF-clauses enormously. I would advise you to write the whole idea down and try to simplify it, as you can see from following example:
I have three cells ("F2", "G2" and "H2"), all can have two values ("Work" or "Home"), and I have created two formulas to calculate a result:
Formula1 : =IF(F2="Home","Home",IF(F3="Home","Home",IF(F4="Home","Home","Work")))
Formula2 : =IF(AND(F2="Work",F3="Work",F4="Work"),"Work","Home")
You see: "Formula1" is based on three nested IF-clauses, while "Formula2" only one.
Yet, both formulas yield the same result!

Need help writing IF Statement

I need some help. I rarely use IF statements in excel, I usually do Index Matches, VLookups etc. So when I came across this, I thought I could come here for some help.
I want to have an IF statement that returns 5 values.
In the picture attached, you'll see 5 levels.
If the value is less than or 0 then 5.
If the value is 0.01 - 5.99 then 4.
If the value is 6 - 12.99 then 3.
If the value is 13 - 29.99 then 2.
If the value is 30 or more then 1.
If anyone can help mem with this, that would be amazing!
Thank You!
It seems to me that this is what you need:
=IF(A8<=0,5,VLOOKUP(A8,$A$1:$B$4,2,TRUE))
I would just go with a vlookup like so:
=vlookup(D2,A4:B8,2,1)
If you are looking for a nested if formula and using the data set shown in the image of your question, then this will work:
=IF(A8=B1,A1,IF(OR(A8=B2,A8<=C2),A2,IF(OR(A8=B3,A8<=C3),A3,IF(OR(A8=B4,A8<=C4),A4,IF(A8=B5,A5,"Out of Range")))))
In this formula, I have used cell A8 as the reference value.
If you do not want to change the direction of your data, then using a nested if statement like the below should work:
If you do not want to use the lookup table, then will be easier to use the LOOKUP function with constants:
=LOOKUP(A1,{0,0.01,6,13,30},{5,4,3,2,1})

CountIF returns 0 with array and criteria in formula

I have a large array of data, consisting of start and end date/time for license use. I'm trying to count how many users are active at the same time.
I'm using the below formula, but I get a return value of 0 some places, which basically shouldn't be possible.
=CountIFs(E$2:E$5616;"<="&E1108;F$2:F$5616;">"&E1108)
Is the approach wrong or is there a better one?
Edit: Added extra screendump showing the 6 places I have a 0 returned. Have run a clean and trim on the data as well, with no changes to the output.
Edit2: Added npciture showing the difference between my two CountIf and Sumproduct outputs. Is there something I'm missing here, the data should be exactly the same so the output should be 1 and 2 for everything?
Try using SUMPRODUCT instead of COUNTIFS, since it isn't susceptible to the same number coercion issues:
=SUMPRODUKT(--(E$2:E$5616<=E2);--(F$2:F$5616>E2))
Try:
=COUNTIFS(E$2:E$5616, "<=" & E1108, F$2:F$5616, ">" & E1108)
Replace , with ;

Combining multiple IF-statements into one formula

I am constructing a formula to act as an extra 'control cell' for my excel worksheet.
The if statements in text with the expected result:
If D2=0 and E2=0 and F2=0 =>""
If D2=0 and E2>0 and F2=0 =>"m of m2"
If D2>0 and E2>0 and F2=0 =>"m2 of m3"
If D2>0 and E2>0 and F2>0 =>"m3"
If D2>0 and E2=0 and F2>0 =>"m2"
If D2=0 and E2>0 and F2>0 =>"m2 of m3"
If D2=0 and E2=0 and F2>0 =>"m"
If D2>0 and E2=0 and F2=0 =>"m"
I'll converting this formula to vba afterwards, but my knowledge of vba is pretty limited so I like to start with just the excel formula.
Thanks in advance.
*edit: so far the formula always returns "m3" so it acts like all the cells are >0 even if they are empty/have a 0 value.
Formula so far (it's in dutch so als=if)
=ALS(D3=0&E3=0&F3=0;"";ALS(D3=0&E3>0&F3=0;"m of m2";ALS(D3>0&E3>0&F3=0;"m2 of m3";ALS(D3>0&E3>0&F3>0;"m3";ALS(D3>0&E3=0&F3>0;"m2";ALS(D3=0&E3>0&F3>0;"m2 of m3";ALS(D3=0&E3=0&F3>0;"m";ALS(D3>0&E3=0&F3=0;"m";""))))))))```
One way to interpret your table of results is that the value is equal to 0 or its not. your table does not cover the possibility of of values being less than 0. With this understanding one possible NESTED IF function would be:
=IF(D2=0,IF(E2=0,IF(F2=0,"","m"),IF(F2=0,"m of m2","m2 of m3")),IF(E2=0,IF(F2=0,"m","m2"),IF(F2=0,"m2 of m3","m3")))
Alternatively in excel you could use the CHOOSE function. Since each result is unique and its based based on binary results you could use the following formula to generate an index number from 1 to 8:
1+(F2>0)+(E2>0)*2+(D2>0)*4
Drop that in a CHOOSE function and its much more shorter manageable then nested IF. It could look as follows:
=CHOOSE(1+(F2>0)+(E2>0)*2+(D2>0)*4,"","m","m of m2","m2 of m3","m","m2","m2 of m3","m3")
now not being a VBA guru either, I am not sure how CHOOSE would translate over to VBA. But that would be another question!
UPDATE: ALTERNATE IF function
=IF(AND(D2=0,E2=0,F2=0),"",IF(AND(E2=0,D2<>F2),"m",IF(AND(D2=0,E2>0,F2=0),"m of m2",IF(AND(E2>0,D2<>F2),"m2 of m3",IF(AND(D2>0,E2=0,F2>0),"m2","m3")))))
There are many ways to go through the logic. In this case I was able to group the IF functions by results.

(Excel) Giving the smallest value between 2 values

Excel data table
I am new to here. If I have any mistake in making new post, Please tell me and I am ready to correct my mistake.
For above pic, I want to extract the 2 smallest values in column D respectively between row 77 and row 84, and between row 84 and 97. The resulting values are shown in P77 and P84 respectively.
How should I write the excel formula for it? Or it needs VBA to code it?
Thanks a lot for your sincere help!
(Update)
data set
above pic is another capture of my data set which filtered the day with "Bullish breaking candle/bearish breaking candle" only.
Thanks
There are lots of functions/ways to calculate Minimum in addition to the MIN function and it is worth being familiar with them as you will require different ones according to your data.
So quick rundown of some of the main offerings:
SMALL function:
I would consider also the more versatile SMALL function
=SMALL(D77:D84,1) in cell P77
=SMALL(D84:D97,1) in cell P84
You put the array (the range of cells to compare) then the k-th smallest item in that range that you want to retrieve e.g. put 1 to get the smallest, as above, comparable to MIN function, or 2 to get the second smallest etc.
Official blurb below:
Description
Returns the k-th smallest value in a data set. Use this function to
return values with a particular relative standing in a data set.
Syntax
SMALL(array, k)
The SMALL function syntax has the following arguments:
Array Required. An array or range of numerical data for which you
want to determine the k-th smallest value.
K Required. The position (from the smallest) in the array or range
of data to return.
AGGREGATE Function:
Consider the even more versatile AGGREGATE function which can cope with hidden rows in the range, errors etc. You can specify a host of additional requirements whilst still getting the minimum value
General syntax for first form:
AGGREGATE(function_num, options, ref1, [ref2], …)
Function 5 is Minimum. Options are viewable at link I gave but 7 is ignore errors and hidden rows. So, you could use:
=AGGREGATE(5,7,D77:D84)
The AGGREGATE option above is the only version that will still return the minimum correctly if there is an error in the range D77:D84 e.g. a DIV/0 error.
SUBTOTAL Function:
Similar to the AGGREGATE function is the SUBTOTAL function.
You can use SUBTOTAL(5, D77:D84) where 5 specifies you want the minimum for the range. This will not ignore errors. SUBTOTAL(105,D77:D84) will ignore hidden rows though.
Simply put the formula '=Min(D77:D84)' in cell P77
and '=Min(D84:D97)' in cell P84

Resources