Hello, I am not a developer so unfortunately I can't code scripts.
I have an issue with this line of code that I have found on youtube,
potentially it could solve my problem but it doesn't work.
I have 1 tab that shows the earning of my portfolio everytime I update it,
so I would like to visualize how is doing with a simple line chart that
update everytime I update the page.
What I have found is this line of code:
/*
EVENT FUNCTION
Each time the spreadsheet is opened or refreshed
append a new entry
on the Trend sheet
for the sum of the TotalGain/Loss column
from the Portfolio sheet.
*/
function onOpen() {
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var portfolioSheet = spreadsheet.getSheetByName('portfolio');
var rng = portfolioSheet.getRange(7,15,portfolioSheet.getLastRow());
var values = rng.getValues()
var total = 0
for (var i = 0; i < values.length; i++) {
if (parseFloat(values[i]) > 0) {
total = total + parseFloat(values[i]);
}
}
var localDateTime = new Date()
var trendSheet = spreadsheet.getSheetByName('Trend');
trendSheet.appendRow([localDateTime, total]);
}
The numbers 7 to 15 are the return for every stocks I have. The most common
error I receive when I update is that it doesn't calculate the fact that I
have losses so it does the sum. sometimes I receive a value equal to 0
which is impossible.
I have another cell that return the sum of those values, I would only like
to take that number but it doesn't work if I change it here var rng =
portfolioSheet.getRange(7,15,portfolioSheet.getLastRow());
Maybe someone can help me. Thanks a lot
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-visualization-api/5b0c2d9f-2496-4ef6-b5f7-7d4211bccffb%40googlegroups.com.