user3116127
user3116127

Reputation: 1

Month-to-date totals

I have an Excel workbook that has several different worksheets in it. The one worksheet that contains the main data has 100's of entries. This sheet also gets a new entry every day in the row column. The first column is the date column that is formatted as date and time.

I need a formula that checks the newest entry's date to see if its month matches the current month and then sums all entries for that month. I know that I am going to use a SUMIF but the hard part is the rest of the formula. I forgot to mention that I need the formula to divide by the number of current month entries used.

Upvotes: 0

Views: 146

Answers (3)

pnuts
pnuts

Reputation: 59475

Since new entries are added daily I am assuming these are in date order ascending, so please try:

=SUMIF(A:A,">"&EOMONTH(TODAY(),-1),AD1:AD100)  

or adjust the AD range to suit (could use AD:AD).

Upvotes: 0

gtwebb
gtwebb

Reputation: 3011

There are a couple ways you could do this and I would suggest using sumproduct formula.

I'm assuming your data has dates in column A starting in row 2, and a value in column B.

In column C you could have a total in each line which is the sum of all rows above the current one that the month matches.

Formula in C2 would be below which can be carried down

=SUMPRODUCT(--(MONTH(A2)=MONTH($A$2:A2)),$B$2:B2)

Otherwise if you have a single cell and just want to get the latest total this formula would do it. This assumes the latest entry will also be the newest date (highest value)

=SUMPRODUCT(--(MONTH(MAX(A:A))=MONTH(A2:A1000)),B2:B1000)

In sumproduct the first part of the formula --(A=B) returns true or false values which equate to 1s and 0s. The second part is just your value columns.

The second formula does the same thing but it compares the month of the newest date to all others in the column.

Gordon

Upvotes: 0

guitarthrower
guitarthrower

Reputation: 5834

Assuming your dates are in A1:A26 and amounts to be summed are in in B1:B26 here is the formula to use.

=SUMIFS(B1:B26,A1:A26,">="&DATE(YEAR(TODAY()),MONTH(TODAY()),1),A1:A26,"<="&TODAY())

This returns the amounts that are in a date that is greater than or equal to the first day of the current month, AND less than or equal to TODAY.

Upvotes: 0

Related Questions