Overview
The OP basically wants to be able to use the spreadsheet functions over the original data without having to scroll across a large number of rows and columns. His background make him think about having custom views and a easy way to change from one to another but Google Sheets doesn't have a built in feature to manage custom views.
Fortunately the fourth requirements are doable by using built-in features and Google Apps Script
Rows could be hidden by using filters but columns only could be hidden manually or by using code.
For 1, and 2 use Google Apps Script to create custom menus that apply the hide/show columns and optionally rows over the "master sheet". This will allow the user to edit the data directly over the "master sheet" and sort it.
Code example
The following code creates a menu for handling the hide/show operations of columns specified in a global variable.
var cols = [1,5,7]; //columns to be hidden/shown
function onOpen() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var menuEntries = [
{name: "Hide", functionName: "hideCols"},
{name: "Show", functionName: "showCols"}
];
ss.addMenu("Custom Views", menuEntries);
}
function hideCols() {
var sheet = SpreadsheetApp.getActiveSheet();
cols.forEach( function(col) {
sheet.hideColumns(col);
}
)
}
function showCols() {
var sheet = SpreadsheetApp.getActiveSheet();
cols.forEach( function(col) {
sheet.showColumns(col);
}
)
}
Functions like GOOGLEFINANCE are only updated when the spreadsheet is open by a user, there isn't a Google Apps Script method that is able to do this. The closest is SpreadsheetApp.flush() but this only makes that the changes made by the script be pushed to the spreadsheet.
One alternative is to rethink your model and take advantage that ...
GOOGLEFINANCE already offer a way to report historic data. The syntax is
GOOGLEFINANCE(ticker, [attribute], [start_date], [end_date|num_days], [interval])
Example
The following formula returns the daily close values of NASDAQ:GOOG
from January 1, 2017 to today.
A1:
=GOOGLEFINANCE("NASDAQ:GOOG","price","1/1/2017",TODAY())
The following formula returns the daily close values of NASDAQ:AMZN
from January 1, 2017 to today.
D1:
=GOOGLEFINANCE("NASDAQ:AMZN","price","1/1/2017",TODAY())
To calculate the daily average, we could not use AVERAGE with ARRAYFORMULA but we could use the +
and /
operands:
G1:
=ArrayFormula((B2:B+E2:E)/2)
Note:
Suggestion: Delete the blank rows at the bottom in order to make the calculation of the daily average just for the rows with data.
The history daily average will be calculate from the start date to the actual date every time that the spreadsheet be recalculated.
Result (extract):
Date Close Date Close Average
1/3/2017 16:00:00 786.14 1/3/2017 16:00:00 786.14 786.14
1/4/2017 16:00:00 786.9 1/4/2017 16:00:00 786.9 786.9
1/5/2017 16:00:00 794.02 1/5/2017 16:00:00 794.02 794.02
1/6/2017 16:00:00 806.15 1/6/2017 16:00:00 806.15 806.15
1/9/2017 16:00:00 806.65 1/9/2017 16:00:00 806.65 806.65
1/10/2017 16:00:00 804.79 1/10/2017 16:00:00 804.79 804.79
Note:
Google spreadsheet functions are only recalculated while the spreadsheet is open, so using a script to be ran while the spreadsheet is not opened by anyone will retrieve the values saved the last time the spreadsheet was online-opened/synced offline changes.
References
Best Answer
If column B has week number and columns E,F,G,H,I,J have quantities for which you need weekly totals, then
query
returns the relevant totals:Alternatively, you can create a pivot table report.