Sum cells that are in current Month in Microsoft Excel - excel

I wish to calculate MTD (Month to Date) of some products. Let's say my data is
Product Sale Date
A 2 27/01/2022
B 4 26/01/2022
A 1 14/12/2021
I wish to sum A products that are sold this month. So my Sumifs function have two criteria. I tried use the below formula but it seems the month function is not working. Any tip is greatly appreciated
=SUMIFS(!B:B,!A:A,"A",!C:C,MONTH(TODAY()))

So you may use any one of the following,
Formula Used In Cell C6
=SUMPRODUCT((MONTH($C$2:$C$4)=MONTH(TODAY()))*($A$2:$A$4=B6)*($B$2:$B$4))
Formula Used In Cell D6
=SUM(IF((($A$2:$A$4=B6)*(MONTH($C$2:$C$4)=MONTH(TODAY()))),$B$2:$B$4))
Formula Used In Cell E6
=SUM(INDEX($B$2:$B$4*(TEXT($C$2:$C$4,"MMM")=TEXT(TODAY(),"MMM"))*($A$2:$A$4=B6),,))
Kindly remember you need to increase the range, i have just shown as per the sample data provided, hope it helps

A possible option is to create a new column "is todays month" with the formula =IF(NUMBERVALUE(MONTH(TODAY())-MONTH(C2))=0,1,0)
Then use =SUMIF(D2:D4,"1",B2:B4)

The sum of sales for product "A" in the current month:
=SUMPRODUCT($B$2:$B$4,(A$2:A$4="A")*1,(MONTH($C$2:$C$4)=MONTH(TODAY()))*1)

Related

SUMPRODUCT with 3 criterias including date

I've been trying to come up with a formula to sum a specific amount.
It has 3 criterias: 1st is an account number: column A; 2nd is a Cost Center number: column C; and 3rd is a date from line i1 to T1 (eg.:i1= jan/2020; t1=dez/2020).
The dates are formated with "date" type: mar/12 on both sheets.
The date on the formula refers to a specific cell $F$2 in order for me to just comeback there, type the month that i want and it automatically calculates the values while taking into account the other criterias.
This is the formula i adapted from some research.
=SUMPRODUCT(Sheet2!$A:$A=Sheet1!$C20)*(Sheet2!$C:$C=Sheet1!$H3)*(Sheet2!$I$1:$T$1=Sheet1!$F2)*(Sheet2!$I$2:$T$635)
This formula currently gives back 0 instead of the value pretended (which is ~631)
Here are 2 prntscreens as form of sample, i hope it helps.
Sheet1 with formula
Sheet2
Thank you.

Excel function for SUMIF (RIGHT = RIGHT)?

It's probably a quick one, but I'm desperate...
How can I put 2 corresponding RIGHT functions into a SUMIF? Or does this need VBA?
The case:
I want the sum of B:B, if any cell of J:J has the same last 4 numbers as A1.
EDIT
Column J shows the date an invoice was payed (e.g. "14. November 2020"). A1 is the headline and includes "Income 2020".
The sum in B14 should show how much money came in in the year the sheet is representing.
SUMIF(RIGHT(J:J;4);RIGHT(A1;4);B:B)
May someone enlighten me?
Thanks a lot!
Thomas
If column J contains true dates, then you can use SUMIFS and DATE:
=SUMIFS(B:B;J:J;">="&DATE(RIGHT($A$1;4);1;1);J:J;"<="&DATE(RIGHT($A$1;4);12;31))
This isn't working because the value in column J is a date. You should use SUMIFS and use a date range.
=SUMIFS(B:B,J:J,">="&DATE(RIGHT(A1,4),1,1),B:B,"<="&DATE(RIGHT(A1,4),12,31))

Excel Sum dynamic range

I would like to calculate the sum of a column total in a table, base on the name of the column header.
For example, below is a table of monthly sales by each person (from cell A4 to M7).
I would like to calculate the total monthly sales in Cell D13 with the month as an input variable (as in Cell B13).
My thought is =SUM(INDEX(B5:M7,MATCH(B13,B4:M4,0))) where I tried to use index and match function to find the range, then use sum function. It returns with an error and I am currently stuck here.
Your help is appreciated.
Using SUMPRODUCT function
In D13 enter formula :
=SUMPRODUCT((B4:M4=B13)*B5:M7)

Get number of days for a month from given month and year EXCEL

Let say cell A1 has year
cell B1 has month
In cell C1 I want the number of days of month given in cell B1 in the year A1
For example: If A1=2016, B1=2, now C1 should return the number of days in February 2016.
What I have tried
In C1
=DAY(DATE(YEAR(A1),MONTH(B1)+1,))
But this does not work
I'd be grateful for a solution.
Consider:
=DATE(A1,B1+1,1)-DATE(A1,B1,1)
Or you may try this...
=DAY(EOMONTH(DATE(A1,B1,1),0))
Less transparent but this will also work
=42-DAY(DATE(A1,B1,42))
format as general
Excel have a lot of functions that are unknown for most users. EOMONTH is the function you need in your case. It returns the last date of the month for a given date.
Consider you have a cell A1 with TODAY function and you want the last date of the month. In B1 you put:
=EOMONTH("A1",0)
So in B1 will show 30/04/2017 (for those whose date format is dd/mm/yyyy).

Count number of occurrences by month

I am creating a spreadsheet with all my data on one sheet and metrics on the other.
On sheet 1 in cells A2:A50 I have the dates in this format (4/5/13). On sheet 2 in cell E5 I have April and I want it to total the number of PO's created in F5.
How can I do this?
I have tried using
=COUNTIF('2013'!$A$2:$A$50,'2013 Metrics'!E5).
I have a feeling that since my range is in 4/5/13 format and my criteria is April that won't work.
I was able to use this formula for total spend by month:
=SUM(IF(MONTH('2013'!$A$2:$A$19)=4,'2013'!$D$2:$D$19,0))
but not luck with how many PO's by month.
Use a pivot table. You can manually refresh a pivot table's data source by right-clicking on it and clicking refresh. Otherwise you can set up a worksheet_change macro - or just a refresh button. Pivot Table tutorial is here: http://chandoo.org/wp/2009/08/19/excel-pivot-tables-tutorial/
1) Create a Month column from your Date column (e.g. =TEXT(B2,"MMM") )
2) Create a Year column from your Date column (e.g. =TEXT(B2,"YYYY") )
3) Add a Count column, with "1" for each value
4) Create a Pivot table with the fields, Count, Month and Year
5) Drag the Year and Month fields into Row Labels. Ensure that Year is above month so your Pivot table first groups by year, then by month
6) Drag the Count field into Values to create a Count of Count
There are better tutorials I'm sure just google/bing "pivot table tutorial".
For anyone finding this post through Google (as I did) here's the correct formula for cell F5 in the above example:
=SUMPRODUCT((MONTH(Sheet1!$A$1:$A$50)=MONTH(DATEVALUE(E5&" 1")))*(Sheet1!$A$1:$A$50<>""))
Formula assumes a list of dates in Sheet1!A1:A50 and a month name or abbr ("April" or "Apr") in cell E5.
Make column B in sheet1 the dates but where the day of the month is always the first day of the month, e.g. in B2 put =DATE(YEAR(A2),MONTH(A2),1). Then make E5 on sheet 2 contain the first date of the month you need, e.g. Date(2013,4,1). After that, putting in F5 COUNTIF(Sheet1!B2:B50, E5) will give you the count for the month specified in E5.
I would add another column on the data sheet with equation =month(A2), then run the countif on that column... If you still wanted to use text month('APRIL'), you would need a lookup table to reference the name to the month number. Otherwise, just use 4 instead of April on your metric sheet.
use count instead of sum in your original formula u will get your result
Original One
=SUM(IF(MONTH('2013'!$A$2:$A$19)=4,'2013'!$D$2:$D$19,0))
Modified One
=COUNT(IF(MONTH('2013'!$A$2:$A$19)=4,'2013'!$D$2:$D$19,0))
AND USE ctrl+shift+enter TO EXECUTE
Recommend you use FREQUENCY rather than using COUNTIF.
In your front sheet; enter 01/04/2014 into E5, 01/05/2014 into E6 etc.
Select the range of adjacent cells you want to populate. Enter:
=FREQUENCY(2013!!$A$2:$A$50,'2013 Metrics'!E5:EN)
(where N is the final row reference in your range)
Hit Ctrl + Shift + Enter
Sooooo, I had this same question. here's my answer: COUNTIFS(sheet1!$A:$A,">="&D1,sheet1!$A:$A,"<="&D2)
you don't need to specify A2:A50, unless there are dates beyond row 50 that you wish to exclude. this is cleaner in the sense that you don't have to go back and adjust the rows as more PO data comes in on sheet1.
also, the reference to D1 and D2 are start and end dates (respectively) for each month. On sheet2, you could have a hidden column that translates April to 4/1/2014, May into 5/1/2014, etc. THen, D1 would reference the cell that contains 4/1/2014, and D2 would reference the cell that contains 5/1/2014.
if you want to sum, it works the same way, except that the first argument is the sum array (column or row) and then the rest of the ranges/arrays and arguments are the same as the countifs formula.
btw-this works in excel AND google sheets. cheers

Resources