I have a google app script which submits info to an organized sheet and would like to create a pivot table with the all information in the sheet. I can do this, but whenever I submit a new row of data to the sheet, it is not automatically included in the pivot table. I have to manually change the range of the pivot table every time I submit a new row of data. Is there any way I can make the sheet/pivot table automatically include the new row of data?
I worked around this issue by only specifying the column range.
For example, if you have row data in columns A to F, set the range of the pivot table to SHEET!A:F
If you add rows now, the new data in those columns will be added to the pivot table.
There is a way. I did exactly that 3 years ago on Sheets.
If you are submitting the new rows using Google Forms, then there is no way.
If you try to programmatically update the range, there is no way either because named ranges need to be deleted then re-added, causing #REF on the pivot.
Now for the good part: If you are adding the new row with a script, do not append it to the end. Instead, keep a fake row at the end (with zero values so pivot is not affected) and insert the new row just before it. Your range (named or not) will update.
Even for the Google Forms case, you might get it to work by pre-adding all blank rows to the response sheet and make the named range include the blank ones too.
I encountered the same problem with the Google Sheet linked to a form. How I solved it:
Edit the Pivot table range to include the empty row after the last row in your sheet.
If your pivot table data range is 'Sheet Name'!A1:S100, change it to 'Sheet Name'!A1:S101.
Add a filter to your pivot table for a column (present in the data range) that will never be blank and set the condition for this column - 'Is not empty'
If you have a column 'Timestamp' (and you're sure it will never be empty), then add this column to the filter, select 'filter by condition' and set the condition to 'Is not empty'.
These steps will filter out the last (empty) row. When you will add a new row to your data, the pivot table will update automatically and you won't have to update the data range again.
In my case what was interfering were the fields in the Pivot's Filters section (highlighted in red below).
Make sure you test without any filters... see if it works. Then add your filters one by one and play with the pivot. Probably the filter(s) is\are influencing the pivot to not update.
Related
So I'm sending data from an app to a google sheet and then trying to format the data. If I pre-format the cells in anticipation of the data, the rows of data end up being appended below the last formatted row. I'm also trying to base other cells off the anticipated data that is being imported, but the rows get appended below the last row with data, even if it's not in the way. For example, if I'm always importing 1 row and 3 columns at a time, I would like to prefill column 4 onwards withe formulas and have my data slot into the same row. Is this possible with google apps script? Or is the only way to have the row of data appended after the last row in the sheet? Ideally, I'd like it to be the first available row with the first 3 columns empty.
Using appendRow when you want to that the new row gets the same formatting of the above rows is "tricky". The safe way to go is to use the script to set the format of the appended row. One way to do this is by using copyTo with SpreadsheetApp.CopyPasteType.PASTE_FORMAT
I have a Google Sheet is being updated through two channels, an App through Appsheet, and an automated workflow from Zapier. Both add new rows for new bookings. The updates which come through the App work perfect, this is the main way of working. Now, I want to add information coming in through Zapier. Problem is that not all the information coming from Zapier is in the right format.
Please see the Sheet here.
If the data comes through Zapier, a new row will be created by Zapier and all columns except for Column C 'Driver ID'. I need this cell to be automatically updated. I can do this with an IndexMatch linking to another sheet with an overview of all the names and ID's. However, Zapier will always create a new row and therefore there will be no formula.
If data comes in through Appsheet all columns will be filled out except for Column E 'Driver Name'. There is no need for this since this information is already included in the Driver ID.
What I want to do is, apply a formula to Column C, if a value appears in Column E. If no value appears in Column E than there is no need for a formula in Column C. How can I trigger the placement of an (IndexMatch) formula for the cell when a certain cell has a text-value?
I would like to add a script to a button I created in Google Sheets. I would like the button to add a new column before my "Month Loss" column. I would like the new column to copy the formulas and formatting of the column to the left.
This will provide an easy way to track my body measurements and help to determine calculate my body fat percentage.
Here is a link to my sheet: https://docs.google.com/spreadsheets/d/1DP0SQpU16YEfPWoE8IRknoqQWu0wrFagzhLflVOkn8M/edit?usp=sharing
A Pivot Table has been created though script. if you try to programmatically update the range, there is no way either because named ranges need to be deleted then re-added which causes on the pivot.
if you are adding the new row by script, do not append it to the end. instead keep a fake row at the end and insert the new row just before it. your range (named or not) will update.
Even for the google forms case you might get it to work by pre-adding all blank rows to the response sheet and make the named range include the blank ones too.
Found this Stack Overflow ticket discuss about Pivot Table, you may also check the solution offered by the community: Google Spreadsheet Pivot Table Range Update Using Scripts
I am new to access and I was wondering how i can only copy the headers from access to excel. There is too much data in the access table and I only need the headers. Thanks!
Filter your table so it doesn't show any data (e.g. right-click in a text column and filter for "Equals: qwerqwerqwer". Then you can copy&paste the empty table.
As pointed out by Wayne (thanks!), this doesn't actually work - Access doesn't copy an empty table.
You need to have at least one record, so the best method is to right-click into the primary key column of any row, and choose Equals <the current value>. This will leave you with one record, now you can Ctrl+A to select all and Ctrl+C to copy.
Create a query for the table that selects all columns, but filters on a unique value for one row. Below is a sample query that will return one row of data with headers. If you dislike the one row, then I think you will be writing some VBA code to get the field names.
SELECT tblLog.eDate, tblLog.eTime, tblLog.Form,
tblLog.User, tblLog.Detail, tblLog.ID
FROM tblLog
WHERE (((tblLog.ID)=1));
You could possibly select all the fields one at a time from the Fields collection of a table, write that to an array and export the array to an Excel spreadsheet.
Or, you could create a new query, go into the SQL view and write:
SELECT Top 1 *
FROM MyTableName
It will give you only the first record of the table. Copy/Paste as text that to an Excel spreadsheet and delete the first row. Voila!
I am having a strange issue regarding in which row of a linked sheet a google form places a new form row. Normally, each form submit adds a row to the sheet, starting with row 2 (row 1 is the header), as expected. If I delete all the rows in the sheet, form submits restart at row 2, as expected. But, now suppose I manually populate say the first 10 rows of the form (again, leaving row 1 as the header, so rows 2-11). Now when I do a form submit, I would expect row 12 to be added to and so on but instead, form starts at row 2 and wipes out my pre-populated row data. It seems that the form and the sheet have an internal "next row number" that is not based on the actual contents of the sheet. Can anyone shed any light one this?
I run into same problem. And found solution (after 2 hours of digging, where is the problem)
You need to use a function
sheet.insertRowsBefore(rowIndex, numberOfRowsToBeInserted)
first to create new rows (space) for your data and AFTER add your data to those created rows.
You can add new rows manually in google sheets of course - it works the same.
Explanation: There is an internal form property which holds a row index where a new form submissions will goes after a form submit.
When you only fill data, the index for new form submissions stays at previous position, so it rewrites your (any) data in cells.
Expect similar behavior when deleting a row data - if you delete only values (by delete key for. eg), then there will stay empty row when new form submission appears. Again you need to use function sheet.deleteRow(index) to delete data and change index of new row for new submissions.
Sounds like you are using the getActiveCell() or getActiveRange() method to find the last row. Whereas, you should be using getDataRange() method to get the last row and columns. getActiveCell() or getActiveRange() methods point to the location of the cursor on the Spreadsheet. Hence, if at the time it was at Row 1 - Col2, that's where it'll insert your info. Refer to this documentation for more information.
This happens by design so that form submissions never overwrite user inserted data. This is well demonstrated in this response[1].
I believe you could resolve problems if you create a script to insert your older data using the createResponse() method[2].
[1] https://support.google.com/docs/thread/10244473/google-forms-inserting-at-top-of-sheet?hl=en
[2] https://developers.google.com/apps-script/reference/forms/form#createResponse()