Reorganizing Google Sheets data dynamically - google-sheets

I'm currently working with Google Sheets to import data from Contact Form 7 in Wordpress. All the data is coming over fine, but I wanted to see about formatting it in more user friendly fashion. I've simplified the example a bit, but the gist of the form I have created allows the user to request multiple versions of a graphic file with different wording as needed, up to 5(my example has just 2 for simplicity sake).
All the data is imported using the CF7 variables and ideally I wanted to clean this up a bit. What I had thought of as a solution was creating a second sheet that pulls in this data submitted in the first sheet into a more user friendly format, as I intended to use this as a work form for a designer to create the requested graphic once the data is received. With each request the name/department/email/date all stay the same, but I'd like to display the version and line 1 and 2 data on another line. Is it possible to reorganize data like this on the fly, so when a new form is submitted and adds data to sheet 1, sheet 2 would then update with the properly formatted info?
Is this even possible to do? I did some looking online, but didn't anything that really related to this type of data manipulation.
Solution:
Here's what ended up working for my example
=ArrayFormula(QUERY({
Sheet1!A2:D,Sheet1!E2:G,ROW(Sheet1!A2:A);
IFERROR(LEN(Sheet1!A2:D)/0),Sheet1!H2:J,ROW(Sheet1!A2:A);
IFERROR(LEN(Sheet1!A2:D)/0),Sheet1!K2:M,ROW(Sheet1!A2:A);
IFERROR(LEN(Sheet1!A2:D)/0),Sheet1!N2:P,ROW(Sheet1!A2:A);
IFERROR(LEN(Sheet1!A2:D)/0),Sheet1!Q2:S,ROW(Sheet1!A2:A)
},"select Col1,Col2,Col3,Col4,Col5,Col6,Col7 where Col5<>'' order by Col8",1))

Yes, it's possible.
One way is to use arrays and the QUERY function.
For simplicity, let say that
Columns A and B have the general information of the order
Columns C and D have the data for version 1
Columns E and F have the data for version 2
Columns G and H have the data for version 3
On the output sheet, add the headers.
Below of them add a formula like the following:
=ArrayFormula(QUERY({A2:B,C2:D,ROW(A2:A);IFERROR(LEN(A2:B)/0),E2:F,ROW(A2:A);IFERROR(LEN(A2:B)/0),G2:H,ROW(A2:A)},"select Col1,Col2,Col3,Col4 where Col3<>'' order by Col5"))
References start on row 2 to skip the headers to avoid to include them on the output sheet.
ROW(A2:A) is used to keep the order
IFERROR(LEN(A2:B)/0) is a "trick" used to "hide" the order (general information) data for the second and following rows for the same order. On the select parameter of the QUERY function, it's referrey as Col5 on the order by clause.
It's assumed that lookup-choice-1 will never be empty.
NOTES:
If more columns were added, the column numbers should be updated accordingly
Don't use the order by clause to sort the result by the general information columns because the "trick" to hide the "labels". If you need to apply a sort, do it' before applying the above formula, you could do this by sorting the source range through the Data > Sort range... feature, so the data is sorted before it's transformed by the above formula.
See also
Sort and filter your data, an official help article describing Data > Sort range...

Related

Google Sheets - Randomize and freeze queried columns

I'm trying to create a dynamic 'worksheet' in Google Sheets to help myself study Chinese.
This is something I'm kind of figuring out as I go, but I'm currently trying to create a template for the basic 'worksheet' that will draw vocabulary from other pages in my document.
Here's a copy of my current version: https://docs.google.com/spreadsheets/d/1U1hclOSo-SM2JuxJB6LXPB4J0UzXt6xJ1B_54ehkALs/edit?usp=sharing
Sheet1 is where I'm currently struggling. The idea behind Column A was that I could create 'switches' to keep the page from updating (Freeze) while I'm actually using the worksheet for studying. Once I've finished and checked my work, I could switch back to (Update) so that the Query will re-run and update to include any new words, etc.
Thus, E2 =if(A2="Update",1,0) is the condition I'm trying to check. 1 in this case would be letting the page update. 0 would be the only other value (Freeze), which would ideally stop the sheet from updating.
Another problem I've run into is that I wanted to use the 'Randomize Range' feature from the right-click menu on the output of my Query, but that doesn't seem to work. I wanted to be able to shuffle the terms so that I am not accidentally memorizing the order rather than the actual information I'm trying to learn.
I don't know which is more efficient: Having the Query grab the definition along with the word and add those to a hidden column, or have a column that matches the word to its definition outside of the Query.
If I could add in another layer of complexity, it would be neat if I could have my worksheet randomly choose between column A and column D (maybe E, too) on my Vocabulary Bank pages so that sometimes it would show me the English term and other times it would show me the Chinese one. (Currently, I'm planning to just have one worksheet for English to Chinese and a second for Chinese to English.)
In the end, I'd like for Sheet1 to work like this:
Column A: Switches
Column B: Terms, grabbed from 'Vocabulary Bank - [etc.]'!A3:A [etc.] being all of the different banks. These are randomly reordered and 'frozen' until the Range switch is changed to 'Update'.
Column C: Hidden, containing the translations of the corresponding words. These update according to a switch.
Column D: This is where I enter my guesses at the translations. There is a switch to enable 'grading' where answers that don't match Column C are highlighted.
Any help would be appreciated. Thanks!

(Google Sheets/Google Forms) I'd like to be able to collect live data from different columns and have them populate one column instead

I'm collecting data from a Google Form that allows the user to choose which language they'd like the survey to be in, and based on his/her answer, the Google Form will utilize branching to lead them to the questions in the language he/she chose. For example, if they choose 'English,' a question they will answer is 'Full Name,' while if they choose 'Español,' they will answer 'Nombre y apellido.'
This leads the spreadsheet to collect the data from those questions into two separate columns. Is there a way to set up the spreadsheet so it organizes the data from the same translated questions into columns? The form will be receiving data constantly. I've tried stacking the columns using this formula template: ={A2:A5;D2:D5}, but the formula simply moved cells whenever data was added from the Google Form. I am collecting multiple points of data in 6 different languages, and I'm really hoping there's a way to organize this data to make it much less cumbersome to wade through.
If you have any ideas, please let me know! I'll try whatever you've got. 😅 Thanks!
You can union the column values, using open ranges, and then filter out the empty values using =QUERY() or =FILTER().
This way you'll be effectively joining values from different columns as one.
For example if you wanted to join data of columns A, D and E, you could do:
Using QUERY
=QUERY({A2:A;D2:D;E2:E}, "select Col1 where Col1 is not null")
Using FILTER
=FILTER({A2:A;B2:B;E2:E}, {A2:A;B2:B;E2:E} <> "")

Combine multi-row source data across separate tabs into one summary tab without using hard references to individual sheet names [duplicate]

This question already has answers here:
How to create INDIRECT array string of multiple sheet references in Google Sheets?
(2 answers)
Closed 2 years ago.
I would like to create a summary sheet that reports the same data from across multiple tabs and doesn't rely on referencing individual sheet names in the formula/code. I have successfully done this when there is only one line of data representing each tab (using getSheetnames or Index scripts).
But, the data I want to summarize has multiple rows from each tab that need to be reported on a summary sheet.
I've successfully managed to combine and report the data from separate sheets into the Summary using a query/array combo where the query range includes each sheet and separated with ";". This can be done using cell references to the Sheetname list as well.
However, this needs to be more dynamic as sheets will be added/removed regularly and I would like to not have to re-write the query every time to add/remove individual sheet names.
SUMIF also works, but with similar limitations.
I believe my main challenge is using a list of sheet names which I can generate (listing one sheet per row) and associating those names formula/code that will produce summary results in multiple rows.
If Sheet names are in Column A, the following formula displays data combined from multiple tabs
=ArrayFormula(query({INDIRECT(A3&"!A2:A200"),to_text(INDIRECT(A3&"!B2:B200")),INDIRECT(A3&"!C2:C200");INDIRECT(A4&"!A2:A200"),to_text(INDIRECT(A4&"!B2:B200")),INDIRECT(A4&"!C2:C200")},"select Col1,Col2,Col3 where Col1 contains 'Project'"))
BUT, I want to reference my Sheetnames list without having to write in actual sheetnames or cell references to the formula.
Here's a link to a dummy workbook with sample.
I realize I'm late to the party on this question, but have you considered a Google Form with 5 questions:
Project?
Phase?
Transaction?
Start?
End?
That way, all your data would be in a single tab. People could input using the form, and you could still have project by project outputs for viewing/analysis using a simple query.
Google Sheets was designed from the ground up to be different from excel in specifically this way. There are all sorts of incentives to condense your data SOURCES while making it easy to disaggregate your ANALYSIS. While Excel is exactly the opposite. It's easy to keep track of things on tons of different tabs, and aggregate it all in one place. Yet there is no such thing as FILTER() or QUERY() to do the opposite.

Query Importrange in Google Sheets Not Importing Correctly

We are using Google Forms to collect data on our students. They use the same Google Form for all students, but as part of the form, they are asked the students name.
The data that ends up being collected you can see on the tab Form Responses 1 on the Google Sheet linked here.
I am attempting to use ImportRange to create a tab for each of the students. The formula that I am using for just one of the students is...
=QUERY(IMPORTRANGE("1nJANDP1fiQunxfxEf-EjwJrnIRICv6kLhYYY9XBXtD4", "Form Responses 1!A:I"),"SELECT * WHERE Col3 = 'Adam N.'")
You can take a look at the tab called Adam N. and you'll see it is kind of working.
One thing that doesn't seem to be working is when there is a text value in columns E-I, that text value doesn't end up showing on the Adam N. tab. Any ideas how I can get both the numbers and the text values to show up?
The other thing that seems to be a problem is the fact that on the Adam N. tab, the very first row has the same headers as the Form Responses 1 tab, but it also has the very first line of data. Any way to remove that?
Importrange is not needed since you are 'importing' from within the same spreadsheet. Also, I'd recommend using the (optional) header argument in query().
It is often noted that users are tempted to mix data types within a column. The query() function will give undesirable output. If a column is intended for numeric values then only numerical values must reside in that column. Date columns must only contain dates and text columns only contain text values.
This does not mean that numbers cannot appear in a text column as long as they are in a text format. So it is important to plan the columns in a table to make sure this rule is maintained regardless if the data table is created manually or via submissions from a Google Form.
Generally, the query() function will assume the greater number of cell types in a column to be that data type. For example, if there are 100 numbers and 20 text values in the same column then a numeric value will be assumed for that column. There is a good chance the text values will just be ignored. One way to avoid this, would be to convert everything to text.
See if this works
=ArrayFormula(QUERY(to_text('Form Responses 1'!A:I),"WHERE Col3 = 'Adam N.'", 1))

How do I use Macros to copy select data from one worksheet to another on Excel?

I need to create a Macro on Excel to keep track of changing contracts. There's already an existing macro that updates the contract data so I need to create another macro...
There are two worksheets. On the first worksheet is a bunch of data with each row representing one contract. There are several categories (Contract #, Date, Price, etc.).
I need to write a Macro that finds only certain contracts fitting specific criteria (like, contacts at a specific date or a certain price), copies and pastes them into the second worksheet.
What I've done so far:
I've figured out a bit of a convoluted way of doing it using IF and OR functions. So using OR I specify the criteria and IF to basically find the corresponding data if things are TRUE.
When things are false, a 0 is entered. The problem is I have tons of rows of zeroes---rows/contracts that didn't fit the criteria. When I try to use the find command (CTRL+F) to find, highlight, and properly delete (with rows shifted up) all the zeroes, Macro doesn't record it and I'm not sure how to write it in the code.
Any insight would help!
Just change your formula to:
=IF(OR(TermSheet!$E40=41220,TermSheet!$M40="bpxx"),TermSheet!E40,"")

Resources