Solved

Find the SUM of the Latest Values in a Table

Posted on 2014-09-18
2
117 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

740 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