Finding sum for last 180 days with a twist

CodePest

New Member
Joined
Jan 16, 2018
Messages
13
I have a table that totals absences for the last 18 months. My table includes collapsible rows and headings with a total row for 2017 and 2018. There is also a total row for each month. Because of my layout my column of days is not consistent. I've included an example below:

[TABLE="width: 500, align: center"]
<tbody>[TR]
[TD="align: center"]A[/TD]
[TD="align: center"]B[/TD]
[TD="align: center"]C[/TD]
[TD="align: center"]D[/TD]
[/TR]
[TR]
[TD]2018[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Jan 2018[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Date[/TD]
[TD]Absence[/TD]
[TD]180 Day Total[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]1/1/2018[/TD]
[TD]1[/TD]
[TD]1
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]1/2/2018[/TD]
[TD][/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]1/3/2018[/TD]
[TD][/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]1/4/2018[/TD]
[TD]1[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]1/5/2018
[/TD]
[TD][/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Total[/TD]
[TD]2[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]February 2018[/TD]
[TD]2/1/2018[/TD]
[TD][/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]2/2/2018[/TD]
[TD][/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]2/3/2018[/TD]
[TD]1[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]2/4/2018[/TD]
[TD][/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]2/5/2018[/TD]
[TD][/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Total[/TD]
[TD]1[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]


While totaling the month and years are easy, I also need to include a column (D) with a running 180 day total that takes into account the breaks for the total rows. I'm just not sure what equation to use. I thought maybe SUMIF but I'm not entirely sure how to execute it. Any help would be appreciated.

Would there be a way to create an equation that calculates a 180 days back from the corresponding date on the running total line, and then finds and matches any dates with absences?
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
The solution was actually quite simple:

SUMIFS(SUMRANGE,DATERANGE,">="&DATE-180,DATERANGE,"<="&DATE)

SUMRANGE represents the column of cells containing the relevant values(Absences in this example). DATERANGE is the range of cells containing dates to consider. DATE is the corresponding date or the date in consideration. This calculation returns the last 180 days of absences starting from a specific DATE.

Hopefully this is helpful to someone else. :)
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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