I'd like to include a SUMPRODUCT within a SUMIF formula.
I'm trying to calculate the sum of product of two cells for a specific row, within a date range.
Right now, I have:
=SUMIFS(A12:E12,$A$10:$E$10,">="&DATE(2018,10,1), $A$10:$E$10, "<="&DATE(2019,9,30))
It's currently summing the entire row for the parts that fall within these dates. I'd like it to sum the entire row for the part falling within these dates, but instead of just summing the row, I'd like it to sum the product of A12 * A9, B12 * B9, etc.
Ideally it would look something like this:
=SUMIFS(SUMPRODUCT($A$9:$E$9,A12:E12),$A$10:$E$10,">="&DATE(2018,10,1), $A$10:$E$10, "<="&DATE(2019,9,30))
But that doesn't work.
Any suggestions would be great, thanks!
Looks like a sumproduct would be sufficient, as it can also take conditions.
=SUMPRODUCT(($A$9:$E$9)*(A12:E12)*($A$10:$E$10>=DATE(2018,10,1))*($A$10:$E$10<=DATE(2019,9,30)))
But without your sample data i can't tell if this works would work on your data. For my sample data the first 2 arrays got multiplied and summed up if the date was between the 2 conditions.
Use an old style array formula with nested IF conditions.They are much more versatile than trying to marry forced cyclic processing with functions that already use cyclic processing.
=SUM(IF($A$10:$E$10>=DATE(2018,10,1), IF($A$10:$E$10<DATE(2019,10,1), A9:E9*B12:E12)))
Finish this with ctrl+shift+enter, not just enter.
In case the dates in A10:E10 contin a time value I've modified your less than to include all of 30-Sep-2019 up to midnight.
Related
I have 2 tables. In first table I have project name and the cost for each project. The project names always start with data (yyyymmdd) for instance 20171201_Project1, 20171202_Project_2 etc. In second table I have dates and Summary of language 1
What I would like to do is to sum up all projects in Sheet2 between 2 dates so if I have done 7 projects between 20171201 and 20171211 I would like to have a formula that will sum them up.
I am currently using this formula:
=SUMIFS(Sheet1!F:F,Sheet1!A:A,">20171201*",Sheet1!A:A,"<20171211*")
However, I always have to put the dates manually. What I want to do instead is to use dates from column A in Sheet2 to indicate the range of dates. You can download the Excel file from here. I pout there new formula that doesn't work as well.
I have tried to use this formula but it doesn't show me correct value.
=SUMIFS(Sheet1!F:F,Sheet1!A:A,">=DATE(LEFT(A2,4),MID(A2,5,2),RIGHT(A2,2))*",Sheet1!A:A,"<=DATE(LEFT(A3,4),MID(A3,5,2),RIGHT(A3,2))*")
Regards,
Adrian
If I understand what you want, SUMPRODUCT may be a better fit.
Something like:
=SUMPRODUCT((LEFT(projCosts[Project Name],8)>=TEXT(A2,"yyyymmdd"))*(LEFT(projCosts[Project Name],8)<TEXT(A3,"yyyymmdd"))*projCosts[Cost])
Where the dates of interest are in A2 and A3 (in this example). Note that, depending on the precise date range you want, you may need to change the equality operators (<,>=) to include/exclude the equal sign.
I have a (large) array of data in Excel of which I need to compute the average value of certain values in one column, based on the values of another column. For example, here's a snippet of my data:
So specifically, I want to take the average of the F635 mean values corresponding with Row values of 1. To take it a step further, I want this to continue to Row values of 2, Row values of 3 etc.
I'm not familiar with how to run code in Excel but have attempted to solve this by using the following:
=IF($C = "1", AVERAGE($D:$D), "")
which (to my understanding) can be interpreted as "if the values (anywhere) in column C are equal to 1, then take the average of the corresponding values in column D."
Of course, as I try this I get a formula error from Excel.
Any guidance would be incredibly appreciated. Thanks in advance.
For more complicated cases, I would use an array-formula. This one is simple enough for the AVERAGEIF formula. For instance =AVERAGEIF(A1:A23;1;B1:B23)
Array-formula allows for more elaborate ifs. To replicate the above, you could do =SUM(IF($A$1:$A$23=1;$B$1:$B$23;0))/COUNT(IF($A$1:$A$23=1;$B$1:$B$23;0)).
Looks like more work but you can create extremely elaborate if-statements. Instead of hitting ENTER, do CTRL-ENTER when entering the formula. Use * between criteria to replicate AND or + for OR. Example: SUM(IF(($A$1:$A$23="apple")*($B$1:$B$23="green");$C$1:$C$23;0)) tallies values for green apples in c1:c23.
Your sample data includes three columns with potential ifs so my guess is that you're going to need array formulas at some point.
Excel already has a builtin function for exactly this use; AVERAGEIF().
=AVERAGEIF(C:C,1,D:D)
Let's say that I have a list of dates starting from A1 and going across...
1/3/2014
2/5/2014
5/5/2015
8/10/2016
...
I'd like to count the number of times a certain month appears in this range. My current solution is that the row below it just contains =MONTH(x1), where x is the column, and then I call a COUNTIF on that row.
I don't think that's so bad of a solution, but it does require a whole bunch of extra cells just to calculate months in my spreadsheet, which isn't really necessary for anything else.
So basically, is there any way to do something along the lines of =COUNTIF(MONTH(range),5) to count, for example, the number of times something occurs in May?
No, you can't do that, COUNTIF function requires a range as first argument - any operation on a range (like using MONTH function) converts that range to an array that COUNTIF doesn't accept
Possible alternative are to use SUMPRODUCT e.g.
=SUMPRODUCT((MONTH(range)=5)+0)
or COUNTIFS like this
=COUNTIFS(range,">="&Z1,range,"<"&EOMONTH(Z1,0)+1)
where Z1 is 1st of the month to count, e.g. 1-May-2013
Of course the SUMPRODUCT version doesn't take account of the year (although you could add that in) while COUNTIFS does
Explanation
In SUMPRODUCT when you use an expression like MONTH(range)=5 that returns an "array" of TRUE/FALSE values like {TRUE;FALSE;FALSE;TRUE}....but SUMPRODUCT here only sums numbers so we need a way to "co-erce" TRUE to 1 and FALSE to 0. You can do that with any mathematical operation that doesn't change the value, e.g. +0, *1 or you can add -- to the front like this:
=SUMPRODUCT(--(MONTH(range)=5))
so we get something like
=SUMPRODUCT(--({TRUE;FALSE;FALSE;TRUE}))
...and that becomes
=SUMPRODUCT({1;0;0;1})
and then SUMPRODUCT sums those values to get 2, i.e. the number of dates in May.
SUMPRODUCT is preferred to SUM purely because you don't need to "array enter" the formula with CTRL+SHIFT+ENTER
See here for a good explanation of SUMPRODUCT and it's many uses
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.
I am trying to create spreadsheet to use in a small retail shop.
I have a workbook which contains expenses figures on a sheet and income figure on another sheet.
We can say that the common ground between the both sheets are the month.
I would like to write a function, which will only select those expenses of a specified month.
Something like -
=SUM(IF( Table4[Month]="January", Table4[Amount]))
// I want the sum of all expenses of a given table for only
// those months which are january etc.
I tried using the above, but it failed.
Actually a more refined solution is use the build-in function sumif, this function does exactly what you need, will only sum those expenses of a specified month.
example
=SUMIF(A2:A100,"=January",B2:B100)
This should work, but there is a little trick. After you enter the formula, you need to hold down Ctrl+Shift while you press Enter. When you do, you'll see that the formula bar has curly-braces around your formula. This is called an array formula.
For example, if the Months are in cells A2:A100 and the amounts are in cells B2:B100, your formula would look like {=SUM(If(A2:A100="January",B2:B100))}. You don't actually type the curly-braces though.
You could also do something like =SUM((A2:A100="January")*B2:B100). You'd still need to use the trick to get it to work correctly.
SUMIF didn't worked for me, had to use SUMIFS.
=SUMIFS(TableAmount,TableMonth,"January")
TableAmount is the table to sum the values, TableMonth the table where we search the condition and January, of course, the condition to meet.
Hope this can help someone!