Solved

excel array formula to calculate min of two variable columns

Posted on 2014-04-21
8
569 Views
Last Modified: 2014-04-21
I have the following data file where column B shows the data, column C shows the max of the data since inception and column D shows the percentage difference between columns C and D.  In cell E1, the minimum of column D is calculated. All straightforward stuff.

I would like to have an array formula that calculates the minimum difference over a set number of days (i.e. last 100 or 200 rows) and does away with columns C and D. So the formula would include lastrow (offset) - the number of rows.(variable).

I have included an example with spreadsheets.

Thanks,
CC
exampleArrayFile.xlsx
0
Comment
Question by:CC10
  • 3
  • 3
  • 2
8 Comments
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 40012653
=MIN(OFFSET(B1,COUNT(C:C)-200,0,200)/OFFSET(C1,COUNT(C:C)-200,0,200)-1)

for the last 200
0
 

Author Comment

by:CC10
ID: 40012750
I get a Value# sign when I enter the formula

Also this does not solve my problem. The formula should work so that for any number of rows chosen, column C will be adjusted.
Column C calculates the maximum value of column B for the number of rows chosen.

Assume rows C and D do not exist. Then, if the number of rows chosen is 100, the formula must calculate MIN(max(last100 rows of columnB)/((last100rowsof columnsB)). I think this is some sort of array formula as each row as has to be calculated.

Does that make sense?
0
 
LVL 43

Accepted Solution

by:
Saqib Husain, Syed earned 400 total points
ID: 40012790
I get a Value# sign when I enter the formula
Enter it as an array formula

The formula should work so that for any number of rows chosen, column C will be adjusted
Change all 200's to a cell address and enter 200 or whatever in that cell.
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
LVL 23

Expert Comment

by:NBVC
ID: 40012797
Try this array formula:

=MIN(N(OFFSET(B:B,COUNTA(B:B)-200+ROW(INDIRECT("1:"&ROWS(1:200)))-1,,1,1))/SUBTOTAL(4,OFFSET(B:B,COUNTA(B:B)-200,,ROW(INDIRECT("1:"&ROWS(1:200))),1))-1)

for 200 last records.
0
 

Author Closing Comment

by:CC10
ID: 40012847
Thanks, thats fine.
0
 
LVL 23

Expert Comment

by:NBVC
ID: 40012919
Are you certain the solution you accepted gives you the expected results?

I tried it and whether you use 200 or replace the 200 with 100 you get the same result of -7.97%!

The formula I gave gives the results you show on ExampleLast200 given the full dataset of ExampleAll.

And if you replace all the 200's with 100's you get the result you show in ExampleLast100.
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 40012946
You are probably right. That formula works only on the 200 sheet. Not on the first sheet.
0
 
LVL 23

Expert Comment

by:NBVC
ID: 40013287
CC10,

In case you decide that my formula was the what you were actually looking for; then in order to use a cell reference to contain the 200 or whatever number of rows you want to test for, try:

=MIN(N(OFFSET(B:B,COUNTA(B:B)-N1+ROW(INDIRECT("1:"&N1))-1,,1,1))/SUBTOTAL(4,OFFSET(B:B,COUNTA(B:B)-N1,,ROW(INDIRECT("1:"&N1)),1))-1)

where N1 contains the number of last rows to test for (e.g. 200)
0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
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 demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

803 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