I have excel data in the following format
Date Amount
01-Jan-16 23.94
12-Jan-16 17.96
26-Jan-16 32.92
03-Feb-16 38.90
20-Feb-16 62.27
26-Feb-16 45.89
I would like to sum the amount field for specific months, that is I would like to sum up the amount in January and also in February separately.
This is the code I have tried thus far which I found in a previously asked question (see Excel Formula to SUMIF date falls in particular month).
=SUM(IF(MONTH(A:A)=1,B:B,0))
It works for January but when I change 1 to 2 it returns zero.
=SUM(IF(MONTH(A:A)=2,B:B,0))
Would sumifs work better?
Here are two other ways of doing it:-
=SUMPRODUCT((MONTH(A2:A10)=1)*B2:B10)
and
=SUMIFS(B2:B10,A2:A10,">="&DATE(2016,1,1),A2:A10,"<"&DATE(2016,2,1))
Change as necessary to get totals for other months.
I have put the results next to the original array formula in this screen shot:-
Use specific range rather than full column. You must use the formula as array formula.
=SUM(IF(MONTH($A$2:$A$1000)=1,$B$2:$B$1000,0))
Press CTRL+SHIFT+ENTER to evaluate the formula as array formula.
Related
I need to come up with a formula that will count the number of rows of a date column. I need greater than 365, 300-365, 299-230 ect all the way down to 30 days. One formula for each will be perfect and as long as I can figure out the first couple, I can get the rest. Help is much appreciated.
The date format in the excel table is: 9/1/2021
A year or older. Seems this may be close but it's giving an error
=COUNTIF(A1:A1000,">="=DATE(YEAR(=TODAY()-1)))
=COUNTIFS(A1:A1000,">="=DATE(DAY(=TODAY()-364)),A1:A1000,"<="=DATE(DAY(=TODAY()-300)))
More than 365 days ago:
=COUNTIF(A1:A1000,"<="&TODAY()-365)
300-365 days ago (need countifs in order to do multiple criteria)
=COUNTIFS(A1:A1000,">="&TODAY()-365,A1:A1000,"<="&TODAY()-300)
Think about using Frequency - this works in most versions of Excel, but has to be array-entered in non-365:
=FREQUENCY(A2:A1000,TODAY()-C2:C11)
The bin values can be entered into the sheet as below or expressed as an array constant in curly brackets. Note that each bin includes values less than or equal to the corresponding cut-point, so the first value is 366:
If all bin sizes were equal, you could use Sequence in Excel 365 to generate the bin ranges.
I have a series of dates and values:
8.12.2018 12
5.2.2019 32
15.7.2019 89
I would like to use something like (SUMIFS(YEAR(A1:A3);2018) but it's not allowed.
I know, I could extract the year in a separate column, but here I want to ask, if it's possible inside the sumifs function?
Although I thought you couldnt, it has proven by #forwardEd, you can alter criteria in such a way to use SUMIFS, however, you could also look into SUMPRODUCT for this exercize:
=SUMPRODUCT(--(YEAR(A1:A3)=2018),B1:B3)
Assuming your dates are valid excel dates and not dates as strings/text then you can use the SUMIFS formula for a year as follows:
=SUMIFS(B1:B3,A1:A3,">="&date(2018,01,01),A1:A3,"<="&date(2018,12,31))
Basically the formula is saying sum all the values in B1:B3 where the date in A1:A3 is greater than or equal to the first day of the year AND less than or equal to the last day of the year. I choose to write the date using the date function as it is easier to recognize than the integer format of the date. If you want to write just the year as a criteria in say cell c2 then replace 2018 in the above formula with c2.
UPDATE
I have not tested it but since the default for a date without time is 00:00:00 it would mean the formula above would cut off December 31 with almost any sort of time associated with it. Therefor the better cut off would be less than January 1st of the following year instead of less than or equal to December 31st. As such you could revise the above formula to:
=SUMIFS(B1:B3,A1:A3,">="&date(2018,01,01),A1:A3,"<"&date(2019,01,01))
or
Where C2 is the year as an integer
=SUMIFS(B1:B3,A1:A3,">="&date(C2,01,01),A1:A3,"<"&date(C2+1,01,01))
Alternative approach (a little bit less elegant solution, but might be more clear to less advanced users):
=SUMIFS(B1:B4,A1:A4,">="&"01/01/2018",A1:A4,"<="&"31/12/2018")
I´ve spent a lot of time with a formula in Excel and I´m still blocked. I hope you can help me.
I have a table in Excel with several values as shown in this
screenshot.
What I´m trying to extract is the number of Fruits sold in a specific month. That is, how many lemons were sold in January 2016, for example. This is the formula I´m using:
=SUMPRODUCT((B3:B38=E4)*(MONTH($A$3:$A$150)=12)*(YEAR($A$3:$A$150)=2015);$C$3:$C$150)
But the result is #N/A as seen in the screenshot.
What Am I doing wrong? Any help, please?
Thanks a lot in advance!
You can use arrays in excel to get this answer
{SUM(IF(MONTH(F$3&"1")=MONTH($A$3:$A$150),IF($E4=$B$3:$B$150,$C$3:$C$150,0),0))}
You can use this Sumproduct formula which uses array logic:
SUMPRODUCT((MONTH($A$3:$A$38)=MONTH(TEXT(G$2,"MMM")&1))*($C$3:$C$38=$F4)*
($D$3:$D$38))
Sumproduct Demo
Part of your problem is your ranges are not equal in length. B3:B38 has to be the same number of rows as $A$3:$A$150 and C3:C150. When rows are not equal things blow up on you.
=SUMPRODUCT(($B$3:$B$150=$E4)*(MONTH($A$3:$A$150)=12)*(YEAR($A$3:$A$150)=2015);$C$3:$C$150)
if you change your header row to be actual excel date format, and then change the cell display format to just show the month (as suggested by csanjose), then you can adjust your sumproduct formula as follows and copy to all cells in your table.
=SUMPRODUCT(($B$3:$B$38=$E4)*(MONTH($A$3:$A$150)=Month(F$3))*(YEAR($A$3:$A$150)=Year(F$3));$C$3:$C$150)
Fill your month-row with the last day of each month, then apply date format to show only month name.
The formula you should use is, for example, in g8:
=SUMIFS($C:$C;$B:$B;$E8;$A:$A;"<="&G$3;$A:$A;">"&F$3)
First column "F" doesn't have a column on the left to compare, so you can put a date in E3 or change a bit the formula (example of F8):
=SUMIFS($C:$C;$B:$B;$E8;$A:$A;"<="&F$3;$A:$A;">2015/12/31")
Take a look at the result
If you don't want to use a pivot table, you can use this formula to get what you need:
=SUMPRODUCT(($B$3:$B$150=$E3)*(MONTH($A$3:$A$150)=1)*(YEAR($A$3:$A$150)=2015)*$C$3:$C$150)
Then drag-fill the cell to copy it to every month column (just make sure you change the month number in the formula (and year if you're doing that too)), and then drag-fill down the columns.
That should work pretty food good :)
Good Luck!
I have following data in excel -
4/2/2002 -0.018255578
4/3/2002 -0.016528926
4/4/2002 0
4/5/2002 -0.016806723
4/8/2002 0.004273504
4/9/2002 -0.006382979
4/10/2002 0.002141328
4/11/2002 -0.004273504
...
I need to sum all entries of 2nd column that fall on Monday. I am using the following formula but it doesn't work-
=SUMPRODUCT(IF(WEEKDAY(A2:A15)=2,1,0),B2:B15)
A related question - how do I select the dates falling on monday from the given list and copy it to a column with a formula?
Any ideas?
thanks
Here is a formula that will do the first question:
=SUMPRODUCT((WEEKDAY(A1:A8)=2)*B1:B8)
This assumes that your data starts in A1. Adjust your ranges accordingly. You can also use an array formula:
=SUM((WEEKDAY(A1:A8)=2)*B1:B8)
I'm not sure that I understand the second part, which may be why your question is getting voted down.
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!