I have a sheet where someone enters numbers into a column every week
Is there a way to have a column that automatically shows the average of the x most recent weeks entered?
So when a new week is entered, the average formula automatically changes the range of columns used for that average
Or possibly via script if needed?
e.g. After the user fills in the new week, I could have them run a script in the sheet to recalculate the average.
Any hints are appreciated.
Not sure how to word a search to look for examples.
And the winner seems to be AVERAGE & OFFSET
This gives me the average for the last 5 entries in the 2nd row
=AVERAGE(OFFSET(C2,0,COUNT(C2:AQ2)-5,1,5))
Related
I have a table in Business Objects in which I have created a monthly date spine and I can see how many items a customer bought in a monthly period. What I am trying to do is count the number of months in which no purchases were made and then find the longest gap across the whole date range.
Here is a mock-up in Excel of what I have got so far in Business Objects:
As you can see I have a running count, but it continues counting every time a blank row is encountered. What I want is that the counting would reset every time a new blank entry is found. I could then find the maximum gap across the date range.
What it should look like is:
The formula I have at present is:
=RunningSum(IsNull([monthly_purchase]);([monthly_purchase];[date]))
How can I adapt this to get the result I want?
Is there a reason you need the running count of months? Or is the main objective to determine the maximum number of months in a row with no purchases?
Prior Month with Purchases = Previous([MonthEnd])
Months Between with No Purchase =If Not(IsNull([Prior Month with Purchases])) Then MonthsBetween([Prior Month with Purchases];[MonthEnd]) -1 Else 0
Maximum Gap With No Purchase =Max([Months Between With No Purchase])
I'm fairly new to Google scripts and so far I only have a functional understanding of 'onEdit'. I want to incorporate Google's time triggers however I don't know how to do it due to lack of understanding.
Here is what I am trying to do:
Objective: Create a spreadsheet that keeps track of metrics on a weekly basis
Current Set up: Currently, the spreadsheet uses 'CountIF' on a queried spreadsheet from multiple users to compile all the data and determine the status of every to-do item at any moment.
Need: I would like to set up a script that takes affect every Sunday. The script would copy the metrics from the previous week and paste them into a row below based upon the start date and date date of the previous week (Which are kept in columns A ad B...Ex: 7/7/2018 & 7/14/2018. If the previous week falls into this date range, the cumulative metrics for that week will paste into columns C-L of that week.
Essentially, row 3 would always keep the running total and then the rows below row 3 would populate with a "total to date" for the given date range.
In your Apps Script editor go to Edit > Current Projects Triggers and select Time Driven > Week Timer.
One column is labeled Checkin Time and the other is labeled Checkout Time and finally I have a column that is labeled Total Time Worked. The cells in the Total Time worked column should subtract the time in the checkout time column from the time in the checkin time column. How do I do this in the script? The times in the checkin and checkout cells are in the military time format which I got from the timestamp upon the form submission.
thanks.
From a Google Form? Do you need to do it in the script? If I'm reading this right, if your checkin timestamp is in column A, and your checkout is column B, you should be able to literally just do =B-A in the total time worked column C. Make sure to set the formatting of the cell to 'Duration', the default will give you HH:MM:SS format, but you can customize it if you just want the hours and minutes.
I have a database for our local real estate listings, there are no dates or timestamp columns.
I would like to be able to get out just the rows that were added in the past day or two.
Can anyone point me in the right direction to get this data out?
EDIT:
Each new row does get a new id number which is incrementally higher, so I can ORDER the results by newest.
Would it be possible to save my query count in a file, or in another database, each day, then calculate the difference and use that as my number of new listings?
"Would it be possible to save my query count in a file, or in another database, each day, then calculate the difference and use that as my number of new listings?"
I understand that you can't change the table structure to add a date...so instead, I suggest to have a cron job at midnight that will create a record with a date and the higher ID at this moment. This way, you will be able to finde a range of ID for a specific date...
If you relayed on query count, you will get problem when you will start to delete some rows...
I have a simple web app and I would like to limit the times the user can use my app.
Basicly my app generate some report, so I should count how many report they generated in a month.
I was thinking to create a database table where I store the month and the times count of generated report. Each time user generate a report the script check the month to see if is current month and if is current month it increase the times count. Instead if the current month is different it sets the times count to 0.
Is this a good start point? or i should make something better?
If it is current month and if is current month it increase the times count. Instead if the current month is different it sets the times count to 0.
You will miss out on the edge case when a user generates reports after a period of approx 1 year. Say he generates 5 times report in October 2012 , and next tries to generate a report in October 2013, then his counter starts from 5 instead of 0 in the current scenario.
I am assuming you are taking two fields to store the information currently (one field for month, the other for count).
So now, Including the year, you will need 3 fields.
To optimise on number of fields, you can instead save the date for the 1st day of current month (2 fields total).
To further reduce the number of fields, you can save the information in one field - save an integer, say yymmxx, where yy is the year, mm is the month, and xx is the number of attempts.
In this approach, to find out previous number of attempts, you will need to do field % 100, and to match if the current month is same, you will need to check for field/100 == yy*100 + mm