Solved

Find the SUM of the Latest Values in a Table

Posted on 2014-09-18
2
115 Views
Last Modified: 2014-09-18
This is a re-packaging of a series of questions recently posed regarding calculations needed on the bottom-most or most-recent data in a table.


Background:
The attached workbook contains an Excel Table showing daily sales data.  Sales are only recorded on weekdays and non-holidays, so there are gaps in the table and that is normal (if not ideal).

There is a need to show the last N-number of days of sales, counting by the sales reported.  Currently, there are a set of formulas (H8 and I8 to determine the rows containing the latest sales within N-days), a helper column (K) of functions used to determine the first applicable row, and a final formula to sum up the total (F8).

Request:
Create a single formula in F8 that replicates this process without the need of the functions in H8 and I8 or the helper column in K.

Note that the formula in F8 can immediately be re-written as:
=SUM(INDIRECT("B"&MAX($K$2:$K$366)&":B"&MATCH(10^10,B:B,1)))
but I've left it "dependent" so you can see the steps better.

The key problem for me has been trying to create an array function that reproduces the result in H8.  I've tried this as an array function ([Ctrl]+[Shift]+[Enter]):
=SUMPRODUCT((COUNT(OFFSET($B$1,ROW(2:366)-1,0,$D$8*2,1))=$D$8)*ROW(2:366))
but Excel doesn't like the ROW(2:366) argument inside the OFFSET and it fails.

Thanks,
-Glenn
SumLatestValues.xlsx
0
Comment
Question by:Glenn Ray
2 Comments
 
LVL 18

Accepted Solution

by:
krishnakrkc earned 500 total points
ID: 40331996
Try this array formula

=SUM(INDEX(Table1[Sales],MATCH(9.999E+307,Table1[Sales])):INDEX(Table1[Sales],LARGE(IF(Table1[Sales]<>"",ROW(Table1[Sales])),D8)-1))

Kris
0
 
LVL 27

Author Closing Comment

by:Glenn Ray
ID: 40332013
I completely forgot about the LARGE function!

My own preference is to swap the two INDEX functions for the first and last cells, but otherwise, this is an excellent solution.

Regards,
-Glenn
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question