sum one month in report

Joanna_gr

Board Regular
Joined
Feb 16, 2002
Messages
149
Hi all! I hope someone can help me on this also. I have a report with fields NAME, DATE, HOURS. Date starts from 1/7/2004 and I have a text box to summarize all hours from that starting date. How can I add a new text box and get the total only for the past month?
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Hi Joanna

I'm not sure I follow this 100% (i.e. the past month?) but in your report footer create a new text box and if you want the total hours for the current month then use the following control source :

=Sum( IIf( [DATE] > DateAdd("d", -Day(Date()), Date()) And [DATE] <= Date(), [HOURS], 0))

If however you want the total hours for the last complete month, then use this as the control source:

=Sum( IIf( [DATE] > DateAdd("d", -Day(Date()), DateAdd("m", -1, Date())) And [DATE] <= DateAdd("d", -Day(Date()), Date()), [HOURS], 0))

HTH, Andrew :)
 
Upvote 0
God bless you Andrew you are always here to help people :pray: Thank you very much. The second solution is what I need. My mistake I wrote past instead of last or previous! Thanks again :biggrin:
 
Upvote 0
I unintentionally made an assumption in my 2nd formula which will give a funny result every now and then (on the last day of a 31 day month when the prior month has 30 days, e.g. 31 May), so use this formula instead :

=Sum(IIf([date] >=DateAdd("m",-1, DateAdd("d",-Day(Date())+1,Date())) And [date] <=DateAdd("d",-Day(Date()),Date()), [hours], 0))

Andrew
 
Upvote 0

Forum statistics

Threads
1,221,907
Messages
6,162,778
Members
451,789
Latest member
Hideoshie

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top