MINIFS formula in a date range and excluding zero - excel-formula

I am using the following formula to find the minimum number in a date range. The formula is working great, but I need to exclude zero from my results.
=MINIFS($J$2:$J$2000,$I$2:$I$2000,">=1/1/2018",$I$2:$I$2000,"<2/1/2018")
I am new to formulas that are this complex and have no idea how to make this work. Note that MINIFS is an Excel 2013 and higher function.

You have literally stated that you want to exclude rows where $J$2:$J$2000 is equal to 0
Just add that as another condition: $J$2:$J$2000, "<>0"

Since MINIFS is an excel 2016 function, this is a formula for previous versions that support the AGGREGATE function.
=AGGREGATE(15,6,$J$2:$J$2000/(($I$2:$I$2000>=date(2018,1,1))*($I$2:$I$2000<date(2018,2,1))*($J$2:$J$2000<>0)),1)
proof of concept:
NOTE: This assumes you want to exclude 0 results from column J. If negative values are also to be excluded, change the <>0 to >0.

This worked when I tested it:
=MINIFS($J$2:$J$2000,$I$2:$I$2000,">=1/1/2018",$I$2:$I$2000,"<2/1/2018",$J$2:$J$2000, "<>0")

Related

How can I fix this Excel formula in ordert to exlude rows from calculation when two different columns has a specific value?

I am not so into Excel and I am finding the following difficulty trying to adapt a pre-existing formula to a new requirement.
Basically I have this original formula (workiong fine):
=SUMPRODUCT((D2:D7)*(B2:B7="BUY"))/SUMPRODUCT((G2:G7)*(B2:B7="BUY"))
This basically calculate an avarange price checking that the value of the B column is "BUY" (basically to exclude when the row is a SELL row). It works fine.
Now I have to change the previous formula excluding also all the row having the H column having value different from "CC". I have try in this way:
=SUMPRODUCT((D2:D7)*(B2:B7="BUY" AND H2:H7="CC"))/SUMPRODUCT((G2:G7)*(B2:B7="BUY" AND H2:H7="CC"))
Basically I tried to add an AND condition checking if the H column value is CC. But it is not working. It give me a syntax error when I try to insert this second version of my forumula.
Why? What is wrong? What am I missing? How can I fix my formula?
AND is used AND(crit1,crit2) not crit1 AND crit2.
AND will not work in this case.
Use * instead:
=SUMPRODUCT((D2:D7)*(B2:B7="BUY")*(H2:H7="CC"))/SUMPRODUCT((G2:G7)*(B2:B7="BUY")*(H2:H7="CC"))
For AND either use this logic: AND(B2:B7="BUY",H2:H7="CC") or (B2:B7="BUY")*(H2:H7="CC") in the second one * stands for AND, but as pointed out by Scott Craner in array formulas (such as SUMPRODUCT) you have to use *.

Excel - Refer to column/range with Networkdays

=COUNTIFS(NETWORKDAYS(C:C, TODAY(), 1),">=" & 5)
I am trying to use something like the above to count any values in Column C (Date column of my dataset) where the working days from then to todays date is greater than 5. Can this be done without creating a working days column?
It's actually not so obvious but NETWORKDAYS does not work with ranges. Arrays however are completely fine. See this post on SuperUser too.
So in your case you could simply use:
=SUMPRODUCT(--(NETWORKDAYS(C:C+0,TODAY())>=5))
Obviously it's better not to reference the whole of column C. Depending if one has Excel O365, you could also just use =SUM instead of =SUMPRODUCT.

COUNTIFS with ISNUMBER and multiple criteria

I'm trying to count if the following range is "Y" or "S" and contains numbers. I'm trying to exclude cells beginning with "_PVxxxxx_".
I cant use
COUNTIFS($A:$A,">0",$B:$B,"Y") + COUNTIFS($A:$A,">0",$B:$B,"S")
because the formula considers "_PVxxxxx_" to be more than 0 and includes them in the calculation.
Can anybody help? Thanks alot!
The function SUMPRODUCT is quite versatile, typically more flexible for testing than COUNTIFS and SUMIFS.
It should do the trick
(see e.g. https://stackoverflow.com/a/27935006/2707864 or https://stackoverflow.com/a/30854706/2707864)
with
=SUMPRODUCT(($A:$A>0)*($B:$B="Y")*(ISNUMBER($A:$A))+...
This works, but I am not sure that you need the part ($A:$A>0)* according to the sample you posted (it doesn't hurt anyway).
PS: If you insist on using COUNTIFS you could use a helper column that uses ISNUMBER and gives, e.g., a suitable numeric result (>0 for numeric data, <0 otherwise). Then you would refer to that column within COUNTIFS.

Using SUMIFS with multiple AND OR conditions

I would like to create a succinct Excel formula that SUMS a column based on a set of AND conditions, plus a set of OR conditions.
My Excel table contains the following data and I used defined names for the columns.
Quote_Value (Worksheet!$A:$A) holds an accounting value.
Days_To_Close (Worksheet!$B:$B) contains a formula that results in a number.
Salesman (Worksheet!$C:$C) contains text and is a name.
Quote_Month (Worksheet!$D:$D) contains a formula (=TEXT(Worksheet!$E:$E,"mmm-yy"))to convert a date/time number from another column into a text based month reference.
I want to SUM Quote_Value if Salesman equals JBloggs and Days_To_Close is equal to or less than 90 and Quote_Month is equal to one of the following (Oct-13, Nov-13, or Dec-13).
At the moment, I've got this to work but it includes a lot of repetition, which I don't think I need.
=SUM(SUMIFS(Quote_Value,Salesman,"=JBloggs",Days_To_Close,"<=90",Quote_Month,"=Oct-13")+SUMIFS(Quote_Value,Salesman,"=JBloggs",Days_To_Close,"<=90",Quote_Month,"=Nov-13")+SUMIFS(Quote_Value,Salesman,"=JBloggs",Days_To_Close,"<=90",Quote_Month,"=Dec-13"))
What I'd like to do is something more like the following but I can't work out the correct syntax:
=SUMIFS(Quote_Value,Salesman,"=JBloggs",Days_To_Close,"<=90",Quote_Month,OR(Quote_Month="Oct-13",Quote_Month="Nov-13",Quote_Month="Dec-13"))
That formula doesn't error, it just returns a 0 value. Yet if I manually examine the data, that's not correct. I even tried using TRIM(Quote_Month) to make sure that spaces hadn't crept into the data but the fact that my extended SUM formula works indicates that the data is OK and that it's a syntax issue. Can anybody steer me in the right direction?
You can use SUMIFS like this
=SUM(SUMIFS(Quote_Value,Salesman,"JBloggs",Days_To_Close,"<=90",Quote_Month,{"Oct-13","Nov-13","Dec-13"}))
The SUMIFS function will return an "array" of 3 values (one total each for "Oct-13", "Nov-13" and "Dec-13"), so you need SUM to sum that array and give you the final result.
Be careful with this syntax, you can only have at most two criteria within the formula with "OR" conditions...and if there are two then in one you must separate the criteria with commas, in the other with semi-colons.
If you need more you might use SUMPRODUCT with MATCH, e.g. in your case
=SUMPRODUCT(Quote_Value,(Salesman="JBloggs")*(Days_To_Close<=90)*ISNUMBER(MATCH(Quote_Month,{"Oct-13","Nov-13","Dec-13"},0)))
In that version you can add any number of "OR" criteria using ISNUMBER/MATCH
You can use DSUM, which will be more flexible. Like if you want to change the name of Salesman or the Quote Month, you need not change the formula, but only some criteria cells. Please see the link below for details...Even the criteria can be formula to copied from other sheets
http://office.microsoft.com/en-us/excel-help/dsum-function-HP010342460.aspx?CTT=1
You might consider referencing the actual date/time in the source column for Quote_Month, then you could transform your OR into a couple of ANDs, something like (assuing the date's in something I've chosen to call Quote_Date)
=SUMIFS(Quote_Value,"<=90",Quote_Date,">="&DATE(2013,11,1),Quote_Date,"<="&DATE(2013,12,31),Salesman,"=JBloggs",Days_To_Close)
(I moved the interesting conditions to the front).
This approach works here because that "OR" condition is actually specifying a date range - it might not work in other cases.
Quote_Month (Worksheet!$D:$D) contains a formula (=TEXT(Worksheet!$E:$E,"mmm-yy"))to convert a date/time number from another column into a text based month reference.
You can use OR by adding + in Sumproduct. See this
=SUMPRODUCT((Quote_Value)*(Salesman="JBloggs")*(Days_To_Close<=90)*((Quote_Month="Cond1")+(Quote_Month="Cond2")+(Quote_Month="Cond3")))
ScreenShot
Speed
SUMPRODUCT is faster than SUM arrays, i.e. having {} arrays in the SUM function. SUMIFS is 30% faster than SUMPRODUCT.
{SUM(SUMIFS({}))} vs SUMPRODUCT(SUMIFS({})) both works fine, but SUMPRODUCT feels a bit easier to write without the CTRL-SHIFT-ENTER to create the {}.
Preference
I personally prefer writing SUMPRODUCT(--(ISNUMBER(MATCH(...)))) over SUMPRODUCT(SUMIFS({})) for multiple criteria.
However, if you have a drop-down menu where you want to select specific characteristics or all, SUMPRODUCT(SUMIFS()), is the only way to go. (as for selecting "all", the value should enter in "<>" + "Whatever word you want as long as it's not part of the specific characteristics".
In order to get the formula to work place the cursor inside the formula and press ctr+shift+enter and then it will work!
With the following, it is easy to link the Cell address...
=SUM(SUMIFS(FAGLL03!$I$4:$I$1048576,FAGLL03!$A$4:$A$1048576,">="&INDIRECT("A"&ROW()),FAGLL03!$A$4:$A$1048576,"<="&INDIRECT("B"&ROW()),FAGLL03!$Q$4:$Q$1048576,E$2))
Can use address / substitute / Column functions as required to use Cell addresses in full DYNAMIC.

How do you figure out the MEDIAN of a column taking into account filters?

I've recently discovered that you can use SUBTOTAL for various functions which allow you to sum up or find totals of a column, even whilst there are filters being applied to it.
However, the list of functions SUBTOTAL has does not include MEDIAN.
Is it possible to find the median of a column of numbers taking into that some rows have filtered out?
Updated to pick up comments from lori_m below
1. Original answer - all xl versions
Courtesy of Aladin Akyurek from this solution
If your data was in A1:A10, array enter this formula with shiftctrlenter
=MEDIAN(IF(SUBTOTAL(3,OFFSET(A1:A10,ROW(A1:A10)-MIN(ROW(A1:A10)),,1)),A1:A10))
2. Updated answer (non-array) - all xl versions
=MEDIAN(IF(SUBTOTAL(3,OFFSET(A1:A10,MMULT(ROW(A1:A10),1)-MIN(MMULT(ROW(A1:A10),1)),,1)),A1:A10))
3. Excel 2010 & Excel 2013
=AGGREGATE(12,5,A1:A10)
True, SUBTOTAL does not include MEDIAN but you can obtain it by first using the SUBTOTAL and then substituting a part of the Excel formula in several or more columns/cells where you need the MEDIAN.
Imagine you used AVERAGE in the Excel subtotal function, then the formula would be for instance =SUBTOTAL(1;E10:E12)
Now, replace all occurrences of "SUBTOTAL(1;" with "MEDIAN(" (without the quotes).

Resources