Is there a way to remap a Google Form query to a different (existing) column in Google Sheets? - google-sheets-query

Is there a way to remap a Google Form question to a different (existing) column in Google Sheets? I had to create a new form question, and its data gets placed in the far right column. That's not convenient for our users. There is already a column in the correct place, but the question for it accidentally was deleted from the form.

Use QUERY to copy the columns into the order you want on a separate sheet and work on that copy.

Related

Link to a google sheets value

Background
I have a google sheet to which I regularly add rows. Each row has an identifier column that remains constant (e.g. the row's "Title"). Rows change positions as I sort the spreadsheet on a column (e.g. the row's "Value").
For each row, I have an associated google doc with extended narrative about the content of the row. The content doesn't belong in the sheet.
The ask
How do I add a link to the google doc such that when I click it, I'm taken to the corresponding row in the google sheet?
What I've tried
I can create a link that specifies a cell in the sheet (like "A1"), however as I add rows and re-sort the sheet, the link no longer points to the correct row.
Thoughts
Can I create a google sheet link that performs a query or filter? In this case a query that searches for a title. I expect it to look something like,
https://docs.google.com/spreadsheets/d/ssid/edit#gid=sid?query=equals('Title', 'MyTitle')
Does this need to be something for which I create a google apps script that's present in the google doc?
Thanks
Can I create a google sheet link that performs a query or filter?
Yes, but it won't take you to the Google sheets file itself. You can create a custom html link. The end point is /gviz/tq. Query can be added with url query parameter tq(say "where A="mytitle") and format can be added with tqx(say html). The link should look like:
https://docs.google.com/spreadsheets/d/${SPREADSHEET_ID}/gviz/tq?tqx=out:html&tq=where%20A%3D%22mytitle%22
out:html uses cookie authentication and should work with private files(when logged in), while out:json requires oauth access tokens.
References:
Request format
Spreadsheets to gviz

Why do two users sometimes see different values from importrange?

I have a very strange problem, the description can be a bit chaotic.
I have two spreadsheets A and B. One sheet inside A is importing data with importrange from the B. The problem is that sometimes two user see different values in that sheet.
Details:
I have two scripts inside A:
one that copies the values from the imported range to another sheet
one that calls that WebApp that changes data in B.
When two users have the A open and one of them makes changes to the B via script and then uses the other script which copies the values, everything is fine. But if one user closes the A, the other makes changes in the B with the script and when the first user reopens the spreadsheet, he will see new values, but if he uses the values copying script, the range containing the values from importrange will show old values. Oddly enough, the script that copies values from that range will copy the new correct values even if we don't see them.
The problem goes away when I manually make some changes to spreadsheet B. I don't know, it's like spreadsheet B doesn't refresh when I make changes via script or something
Do you have any ideas what is the reason for this and maybe how to solve it. I think that I can get round this problem but I would not.
Two Google Sheets users might see diffent values on the same spreasheet because formula calculation (including those that make API calls like IMPORTRANGE) are triggered by user actions like opening or edited the spreadsheet.
Some function also might recalculated by changes made by scripts so it's actually possible that an script could "see" different values than those that are seeing by the users.
If you need that the users see the same values, should consider to periodically "freeze" them i.e. make a copy of the spreadsheet then replace the formulas by their results.
Another option is to share the screen rather than relaing on the "real time" collaboration feature of Google Sheets.

Use numerical answer in Google Form to select row number in Google Sheets for dynamic text in Google Form?

I would like to use Google Forms to assign categories to a list of sources in Google Sheets. I want to use Google Forms in specific because I need to create a pipeline for a group of people that is not familiar with programming. Google Forms is easy to use while still leading to a highly standardized output that I can subsequently import into R and analyze. Furthermore, Google Forms provides a better display of large amounts of texts (around 200 words) than Google Sheets.
Ideally (and taking into account Google Forms' relatively limited functionality with regard to using answers to previous questions to dynamically show next questions), I'm looking for a structure that looks somewhat like this:
Question 1: Manually provide number of source that you want to categorize.
Use answer to Question 1 to display title source and description of source as text, which are pulled from a row in a Google Sheet that corresponds to the answer to Question 1.
n questions about the source that is displayed, which are always the same (thus static).
Submit form (and show option to submit another response).
The answers to the questions should be automatically written to a Google Sheet, with columns for each question and a new row for each submitted form (just like usually would happen for a Google Form).
Although I don't think the set-up is very difficult or sophisticated, I'm struggling with how to get this to work - definitely due to my inexperience with using Google Apps Script, and not knowing the exact limits of Google Forms' functionality.
Questions
If possible, how can I create one form (prob. using Google Apps Script) that performs step 1 to 4? If this is entirely impossible to use previous answers for subsequent answers in Google Forms, how can I create a form for step 1 (again prob. using Google Apps Script), which then automatically redirects people to a second form for step 2 to 4, based on the answer on the first form?

Hiding columns by client Google Sheets

Just wondering if there are any ways to hide columns (client-side) for different users accessing the sheet?
I know you can create filter views that allows users to view and edit without having to change the actual orientation of the sheet, but I can't seem to find any way to hide columns while creating a filter view.
Any help is appreciated. Thanks.
One solution perhaps to your problem is to structure your data across several spreadsheet documents and give access to different people to each sheet.
Let's say you have a have a master spreadsheet containing all the data as a single source of truth. Then you can use an import formula in a different spreadsheet document to display certain data from the master spreadsheet.
The slave documents can be projected as need and will update automatically when the master spreadsheet is changed. Below are some formulas that can do this
Generic import data formula
=IMPORTRANGE("spreadsheet_url,Sheet1A:A")
Import formula to import only display certain - need to project the whole sheet from being copied etc.
=QUERY(IMPORTRANGE("spreadsheet_url","Sheet1!A1:C"),"SELECT Col1, Col3",0)

How to hide certain columns for a user?

On a shared Google spreadsheet:
I don't want a specific user in my domain to view columns with sensitive data, but this person should still be able to edit the rest of the spreadsheet.
I tried creating a 'master' spreadsheet and using importrange to bring the data into a 'shared' sheet, but once I edit any cell in the shared spreadsheet, importrange no longer works as the sheet is emptied out.
Is there a quick way to do this, maybe using scripting?
After some research and trying various different options, I was finally able to achieve what I want using the importrange function.
At first, I tried using a combination of hide columns & protect range, but this wouldn't work because a simple copy & paste would reveal the contents of the hidden columns.
Solution: The 'master' spreadsheet does not have any sensitive column data and can be shared with everyone in the organization... I then ADD the sensitive data to a new spreadsheet and use importrange to grab contents from the 'master'. (Previously I had the roles reversed, but this didn't work)
You may want to add unique keys per row entry so that sorting etc won't mess things up when you zip-up the sensitive data and the 'master' data.
I came here looking for a way to share only certain columns of a spreadsheet with a customer, but not all.
As noted in the other answer, using =IMPORTRANGE works well, but a clever customer could simply edit the function and see the other columns.
My solution was to first create a 'proxy' spreadsheet that imported only the columns I want the customer to see. This proxy spreadsheet is not shared.
Then, I created another spreadsheet that imported the columns from the proxy, and shared that spreadsheet with the customer. This way, even with edit privileges, it's impossible for him to see anything that isn't on the proxy spreadsheet.
A bit clunky to be sure, but it worked perfectly for my situation.