Google Sheets - Randomize and freeze queried columns - google-sheets

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!

Related

Automated Number Distribution in Spreadsheets

Beginner here!
Here's a spreadsheet trying to show what I mean.
Suppose I have data for metrics in comparison to my competitors.
The metrics are sorted highest to lowest and I want to turn the names of the other companies into "Company 1, Company 2, etc." along with the order of the metrics. Myself ("Me") remains unchanged.
With every data set the competitors could be different companies, and I could be ranked in a different position. The number of competitors could range from 1-20.
Is there a way to automate the green fields in the spreadsheet so that I can just paste the data and the competitor numbering stays constant no matter where I appear in the list?
Thank you!
Lighter Torches, I've added a sheet named "Erik" to your spreadsheet.
I've placed an array formula into two cells: G5 and J5. They are the same except for the relative cell references. Since it is an array formula, the single formula in G5 "runs" the entire data set generated in G5:H; likewise, the formula in J5 "runs" the entire data set generated in J5:K. Array formulas do not require dragging/copying to other cells.
Here is the G5 formula:
=ArrayFormula(QUERY(SPLIT({"Me"&"^"&IFERROR(VLOOKUP("Me",A5:B,2,FALSE),"NA");"Company "&ROW(INDIRECT("A1:A"&COUNTA(FILTER(A5:A,A5:A<>"",A5:A<>"Me"))))&"^"&SORT(FILTER(B5:B,A5:A<>"",A5:A<>"Me"),FILTER(B5:B,A5:A<>"",A5:A<>"Me"),FALSE)},"^"),"Select * Order By Col2 Desc"))
In your sample data, the companies are already ordered by rank, best to worst. But in the real world, it seems that may not always be the case. With that in mind, you'll notice that I moved your top performer to the bottom in the second data set. I've written the formulas to account for this (i.e., they will order the companies in the correct order whether they were originally in the correct order or not).
Also, if "Me" for some reason doesn't appear in a raw-data list at all, it still shows up, unranked, at the top of the generated list. Again, I tried to account for real-world what-ifs in the formula.
Finally, I added a sheet-wide custom Conditional Formatting rule that applies bold to any occurrence of the word "Me," since it seemed you were doing that manually. As such, you can type the sole word "Me" in any cell in the sheet, and it will automatically be formatted bold. You can see this rule by selecting Format > Conditional Formatting from the menu, then clicking on the rule you see in the window that appears.

Reorganizing Google Sheets data dynamically

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...

Google Sheets Formula for Pulling Specific Values in Two Ways

I'm trying to do a couple of different things with a spreadsheet in Google and running into some problems with the formulas I am using. I'm hoping someone might be able to direct me to a better solution or be able to correct the current issue I'm having.
First off all, here is a view of the data on Sheet 1 that I am pulling from:
Example Spreadsheet
The first task I'm trying to accomplish is to create a sheet that lists all of these shift days with the date in one column and the subject ("P: Ben" or S: Nicole") in another column. This sheet would be used to import the data via a CSV into our calendar system each month. I tried doing an Index-Match where it used the date to pull the associated values however I found that I had to keep adjusting the formula offsets in order to capture new information. It doesn't seem like Index-Match works when multiple rows/columns are involved. Is there a better way to pull this information?
The second task I am trying to accomplish is to create a new tab which lists all the dates a specific person is assigned too (that way this tab will update in real time and everyone can just look at their own sheet to see what days they are on-call). However, I run into the same problem here because for each new row I have to change the formula to reflect the correct information otherwise it doesn't pull the correct cell when it finds a match.
I would appreciate any and all information/advice on how to accomplish these tasks with the formula combination I mentioned or suggestions on other formulas to use that I have not been able to find.
Thanks in advance!
Brandon. There are a few ways to attack your tasks, but looking at the structure of your data, I would use curly brackets {} to create arrays. Here is an excerpt of how Google explains arrays in Sheets:
You can also create your own arrays in a formula in your spreadsheet
by using brackets { }. The brackets allow you to group together
values, while you use the following punctuation to determine which
order the values are displayed in:
Commas: Separate columns to help you write a row of data in an array.
For example, ={1, 2} would place the number 1 in the first cell and
the number 2 in the cell to the right in a new column.
Semicolons: Separate rows to help you write a column of data in an array. For
example, ={1; 2} would place the number 1 in the first cell and the
number 2 in the cell below in a new row.
Note: For countries that use
commas as decimal separators (for example €1,00), commas would be
replaced by backslashes () when creating arrays.
You can join multiple ranges into one continuous range using this same
punctuation. For example, to combine values from A1-A10 with the
values from D1-D10, you can use the following formula to create a
range in a continuous column: ={A1:A10; D1:D10}
Knowing that, here's a sample sheet of your data.
First Task:
create a sheet that lists all of these shift days with the date in one
column and the subject ("P: Ben" or S: Nicole") in another column.
To organize dates and subjects into discrete arrays, we'll collect them using curly brackets...
Dates: {A3:G3,A7:G7,A11:G11,A15:G15}
Subjects: {A4:G4,A5:G5,A8:G8,A9:G9,A12:G12,A13:G13,A16:G16,A17:G17}
This actually produces two rows rather than columns, but we'll deal with that in a minute. You'll note that, because there are two subjects per every one date, we need to effectively double each date captured.
Dates: {A3:G3,A3:G3,A7:G7,A7:G7,A11:G11,A11:G11,A15:G15,A15:G15}
Subjects: {A4:G4,A5:G5,A8:G8,A9:G9,A12:G12,A13:G13,A16:G16,A17:G17}
Still with me? If so, all that's left is to (a) turn these two rows into two columns using the TRANSPOSE function, (b) combine our two columns using another pair of curly brackets and a semicolon and (c) add a SORT function to list the dates in chronological order...
=SORT(TRANSPOSE({{A3:G3,A3:G3,A7:G7,A7:G7,A11:G11,A11:G11,A15:G15,A15:G15};{A4:G4,A5:G5,A8:G8,A9:G9,A12:G12,A13:G13,A16:G16,A17:G17}}),1,TRUE)
Second Task:
create a new tab which lists all the dates a specific person is
assigned too (that way this tab will update in real time and everyone
can just look at their own sheet to see what days they are on-call).
Assuming the two-column array we just created lives in A2:B53 on a new sheet called "Shifts," then we can use the FILTER function and SEARCH based on each name. The formula at the top of Ben's sheet would look like this:
=FILTER(Shifts!A2:B53,SEARCH("Ben",Shifts!B2:B53))
Hopefully this helps, but please let me know if I've misinterpreted anything. Cheers.

Google Spreadsheet: Query String and Numeric (Involving math formula)

Sorry about the imprecise title. Allow me to elaborate. I'm currently in the process of making 'Order' sheets for the small retailer i work for. Some items are easy to count due to low inventory while other items are abundant and difficult to count but easy to gauge whether we ought to order them.
When an employee takes a store count, the on-hand number they put down is contrasted with a minimum. The minimum is our lower threshold. The minimum is subtracted by the input quantity and a formula produces a third column, "Order". If the number in the order column is < 0 then a query function on a separate sheet will copy the entire row. To be clear, there are three columns, "On Hand", "Minimum", "Order", with the "Order" column containing the following mathematical formula:
="Minimum" - "On Hand"
[Cells are specified so that it would look more like "=B2-A2".]
However, I'd also like to include the ability for employees to put a simple 'x' in the count spot, signifying that we need to order the product without having to count every single instance of the item. I'd still like to include the ability for them to enter a number if they so choose. I'd like for them to be able either the number or the 'x' in the same column. I'm currently using the following query function:
=QUERY('String(Fail)'!A:D;"select * where A contains 'x' or C > 0")
[The above is from a sheet I'm experimenting with. I will provide a link below in case you're more hands-on.]
The issue arises when the formula in the "order" column outputs any sort of number. If the formula is functional, no row marked with an 'x' is copied to the new page via the query command. If any row produces a numeric, no 'x' rows are copied over at all. I've experimented a bit but am at a loss as to where to go next.
The sheet I'm currently experimenting with is linked below. If you'd like any additional information I'd be happy to provide it. I'm relatively new to all of this so excuse my stupidity. I do recognize that I could very likely make a script for this but am not well versed in scripting with Google Apps and enjoy the immediate benefits of the query function.
Any help is welcome. Thank you.
Experimental Spreadsheet
All the values in a column need to be of the same type in order to be evaluated by QUERY. The mix of 'x' and numbers is confusing things.
If you use the Format menu to ensure all the values in column A are Plain Text, then your Query will work. (Formatting a numeric value as plain text does not stop it from working in a numeric calculation, so your column C survives.) Here's a screenshot of your query, after doing that formatting:
Based on your specification, your query needs to have the comparison to zero reversed, like this:
=QUERY('String(Fail)'!A:D;"select * where A contains 'x' or C < 0")
^^^

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