Drop-down list based on value on another cell in another sheet - google-sheets

I have searched for this question and found some useful tips but I can't seem to figure out the answers that they provide, so here's the scenario:
Top image: Sheet Name is Animals
Bottom Image: Sheet Name is Health
So the sheet Animals Column A (Owner) contains the data for dropdown list in sheet Health Column A (Owner).
What I want is in sheet Health if I choose CoopB (on dropdownlist Based on sheet Animals) I want the Column B (ETN) row 2 to become dropdownlist and the choices is based on the value of CoopB in sheet Animals.
Example: On sheet Health
| Column A (Owner) | ColumnB(ETN) |
|------------------|--------------|
| CoopB | CW-011110 |
| CoopC | CC-111101 |
| Coop1 | Coop1-0001 |
Note: on Sheet Animals Column C (Owner) value can be repeated, for example, we can expect CoopB value to appear repeatedly but on Column D (ETN) data are unique.

You can work similarly here, this time a Control sheet seems like a little less overkill.
Let's create a sheet called Control
In Control!A1 put "Owner"
In Control!A2 put =UNIQUE(Animals!C2:C)
In the data validation of Health!A2:A put the range Animals!A2:A
Now you can select the unique pet owners.
For a single Owner
For a single owner (in Health!A2) you could
In Control!B1 put "ETN"
In Control!B2 put FILTER(Animals!D2:D, Animals!C2:C = Health!A2)
For multiple Owners
For multiple owners we need to use the control sheet some more
In Control!B2 put =Health!A2:A so we have a mirror of our selections in Health
In Control!C2 put =IFERROR(TRANSPOSE(FILTER(Animals!D2:D, Animals!C2:C = B2)), "").
Drag the formula down however far you think you may need it (I could not get this to work with an Array formula)
Set the data validation in Animals!B2 to Control!C2:Z2, in Animals!B3 to Control!C3:Z3 etc.
You have to do this manually unless you want to write a script that fills in the data validation rules for you

Related

How do I code a formula to apply to an entire column in Google sheets, even when you insert a new row?

I have a basic cash flow Google Sheet that I use to track my personal finances, cash in and out of my checking account.
Here's basically what it looks like:
Column A Column B Column C
Row 1 | Water bill | -50.00 | 400.00
Row 2 | Credit card | -300.00 | 100.00 >> the formula here is =sum(C1,B2)
Row 3 | Paycheck | 2000.00 | 2100.00 >> the formula here is =sum(C2,B3)
I project this out a full year. Anytime I want to add a row, I have to manually apply the formula in column C, and then I also have to fix the formula in the row just below it, which then fixes the problem for the rest of the sheet.
In Google Sheets, Is there a way for me to hard-code a formula for Column C that would allow me to insert a new row and always have it math perfectly without having to manually add the formula, and fix the formula in the row below it?
Let me know if there would be an easier way to do this by making fundamental changes to how it's setup - this is just how I've done it for so long, and I'm looking for a way to automate this going forward.
I've heard array formula might be helpful, but I'm not sure how to set it up.
There are many kinds of ArrayFormulas and LAMBDA functions. I suggest you look into them for different cases and uses. There is one kind in particular that would serve to your purposes:
=SCAN(0,B2:B,LAMBDA(a,v,a+v))
If you put this in C2 you'll have a cumulative sum row by row. Try it and let me know!
If you want to hide the results if column B is empty you can use another ARRAYFORMULA to check if B is empty it returns empty, either way returns the SCAN result:
=ARRAYFORMULA(IF(B2:B="","",SCAN(0,B2:B,LAMBDA(a,v,a+v))))
If you need to insert a new row in between then it's quite tedious as it will mess up the formulas below it, but if you just keep appending a new entry on the bottom row, then the formula will smartly mimic the behavior above it. Then you can simply do this:
Select the current last row, then click the small dot at the end and drag it down to as much as you want
OR, Ctrl+C (Copy) the last row, then select as much empty rows beneath it as you want, then Ctrl+V (Paste)

Google sheets - select multiple columns for data validation

I'm new on google spreadsheets, and I'm having this little problem:
I want to create a project manager with an external spreadsheet just for customer-info. In my "main-hub" sheet, I have created a dropdown menu on B11 which copys the customer names from the extrenal sheet. That works fine.
Now the problem I am trying to solve: I want to keep the drop-down menu on B11, i dont want to add any new drop down menus. Whenever I select an item from the menu on B11, additional information about the customer should be inserted into different cells in different columns. Example:
| __________ B11 __________ | __________ J11 __________ | __________ K11 __________ |
Selected Name dynamicly inserted data 1 dynamicly inserted data 2
Please keep in mind, I really don't want to add any new drop down menu, I want to keep only this one for the names of the customers.
What you're looking for is "VLOOKUP". This is a Formula where you can define a specific range and select the part you want to display. I've edited your spreadsheet.
=IFERROR(VLOOKUP(A2;'Customers static'!$A$2:$C$5;2;FALSE);"")
IFERROR Value, [value if error]
VLOOKUP Search key, area, index, is sorted
Seeing that you have not solved your answer. I have created a new sheet in your spreadsheet showing you a possible answer.
Possible solution
Basically you can have a dynamically expandable sheet with the use of ARRAYFORMULA.
Which is kind of basically repeat this operation for the whole range. In this case you just would need to put one formula for each column:
=ARRAYFORMULA(IFERROR(VLOOKUP(A:A;'Customers static'!A2:D;2;FALSE)))
Look how instead of using a single value for VLOOKUP you are using the whole range and ARRAYFORMULA will handle that. Therefore you just need to write the formula at the top of each column, changing the index for every single column in the original data.
You can take a look in the Raserhin's help on the sheet you have provided.

Link tables and combine columns between them

My single dataset (generated from a large spreadsheet) is split into multiple tables. The relevant information is the dates and a numerical value assigned to them.
The data is organized as such on each table:
Start Date | End Date | Return Value
A1 | B1 | C1
A2 | B2 | C2
A3 | B2 | C3
The start and end dates are always quarter start and quarter end dates. The value C is always numeric. Each table represents a specific account. Some of these tables don't start until later dates (So Table 4 might have a start date equal to A3, for example).
I would like to group up these tables so the final report is organized as such:
Date range A1 - B1
Table1.C1 | calc(Table1.C1)
Table2.C1 | calc(Table2.C1)
Table3.C1 | calc(Table3.C1)
etc.
And on each detail line where TableX.CY is listed, perform relevant calculations using formulas.
The formulas I've already figured out and gotten sorted, but I'm lost at the best way to refer to each table without creating brand new formulas per table. IE, I don't want to create calcTable1(Table1.C1), calcTable2(Table2.C1), and so on, since there are over 40 tables in this.
How can I link these tables together so that the result set that CR is working with can be easily organized to produce this sort of report?
You can link tables in the Database Fields -> Database Expert -> Links tab.
If you wish to perform these calculations via SQL before they even reach the report, you can do so in the Database Expert by using the Add Command option to write your on SQL formulas.
Otherwise you want to group based on a date range. So you should probably first create a formula to return the format Date range A1 - B1. Then create a group based on that formula you just made.
To add a group, go to Insert -> Group and select your formula as the subject of the Grouped By field.

import data from sheet to another

hi I have a spreadsheet file contains a names of books at column A and the type of the books in column B.
and at the same file I have another sheets each one contains a specific type of books ex: sheet 2 contains the history booksK sheet 3 contains science ..etc
my Question is :
how to import the books from sheet1 (which contains all books)
to the other sheets dependeing on the type name
(take from sheet 1 to sheet 2 all books its type is history)
I tried this formula: =QUERY(IMPORTRANGE("sheet key","Sheet1!A:C"),(select* where COLUMN(B) contains"history")) but it doesn't work ......
Either
=filter(books!A:B, books!B:B = "novel")
or
=query(books!A1:B, "where B = 'novel'")
will work.
So your data looks like this, sheet is named "books" and other sheets are named by book types:
__| A | B |
1 | Who Moved My Cheese? | Self-help |
2 | the hunger games | novel |
3 | the winner stands alone | novel |
You can use filter() function instead of query(). Here is formula to your 'novel' sheet:
=filter(books!A:A, books!B:B = "novel")
"books!" is reference to your sheet that contains data and "novel" is the type to search for. Now you can use this formula for every other sheet by changing only search term "novel" to whatever is desired.
=iferror(QUERY(IMPORTRANGE("https://docs.google.com/spreadsheets/d/[YOUR_KEY_FROM_URL]/edit","Title of Sheet You are Using!A2:I42"),"select * WHERE Col5 CONTAINS 'Towel'",1),"no values yet!")
Lets break it down a bit
IFERROR allows you to display a user friendly message if this fail because no data is returned
QUERY allows you to specify the search criteria. You can omit this if you simply want to import the range of cell regardless.
IMPORTRANGE Use the url provided, then fetch this sheet, looking at these ranges (top left, to bottom right)

Writing BDD feature files shorter and cleaner

I have s lot of scenarios that are identical, they only differs by data which are passed to them.
This is example:
Feature: Linking facts from a report into Excel document
In order to link facts to an Excel document
As an user having access to report
I want to click on fact's value in the report
Scenario: Any uri item
Given I am logged as admin with admin
And I have selected Sample Project
And I have chosen to view report presentation view containing data from factcollection1 and all periods and all clients
When I click on excel cell C2
And I click on the value in 2 column of the row entitled any uri item
Then Excel cell C2 should contain value some internet address
Scenario: Base64 binary item
Given I am logged as admin with admin
And I have selected Sample Project
And I have chosen to view report presentation view containing data from factcollection1 and all periods and all clients
When I click on excel cell F3
And I click on the value in 2 column of the row entitled base64 binary item
Then Excel cell F3 should contain value asdf
Scenario: Boolean item
Given I am logged as admin with admin
And I have selected Sample Project
And I have chosen to view report presentation view containing data from factcollection1 and all periods and all clients
When I click on excel cell J3
And I click on the value in 2 column of the row entitled boolean item
Then Excel cell J3 should contain value true
I would like to shorten this to look something like following:
before scenario:
Given I am logged as admin with admin
And I have selected Sample Project
And I have chosen to view report presentation view containing data from factcollection1 and all periods and all clients
scenario:
When I click on excel cell XX
And I click on the value in YY column of the row entitled ZZ
Then Excel cell YY should contain value WW
and than some table data, like:
| XX | YY | ZZ | WW |
| C2 | 2 | any uri item | some internet address |
| F3 | 2 | base64 binary item | asdf |
| J3 | 2 | boolean item | true |
I found an solution.
There is an scenario outline with this ability.
Scenario Outline: display label in selected language
Given I am logged as <username> with <password>
And I have clicked on <button> button
Then result should be some result
Examples:
| username | password | button |
| john | doe | first |
| foo | bar | second |
You could use Scenario Outline instead of Scenario. Your example would look something like this:
Scenario Outline:
Given I am logged as admin with admin
And I have selected Sample Project
And I have chosen to view report presentation view containing data from factcollection1 and all periods and all clients
When I click on excel cell '<Cell>'
And I click on the value in '<Column>' column of the row entitled '<Row>'
Then Excel cell '<Cell>' should contain value '<CellValue>'
Examples:
| Cell | Column | Row | CellValue |
| C2 | 2 | any uri item | some internet address |
| F3 | 2 | base64 binary item | asdf |
| J3 | 2 | boolean item | true |
This is a very interesting question and I have spent some time researching what I call "data driven Specifications". This is partly inspired by the "row-test" or "data-driven-test" features that many common test frameworks offer.
Not that I use the terms "Scenario" and "Specification" synonmous, however I prefer the latter.
Similar to a normal unit test, a BDD specification is composed of three parts. A common template used is the "Given X When Y Then Z" formula. What you have discovered is that for a lot of your specifications the "X" part stays the same. Whenever I encounter such a situation, I try to create a Fixture class to abstract this. For example, one of those classes might be a LoggedInUserFixture which sets up a logged in user and makes it available to the test.
Very often, you'll find the need to compose this fixture with other fixtures, to create the setting for your specification. For example you may need a LoggedInUserFixture and a UserWithSampleProjectSelected for a single Specification. The easiest way to do this is to create another fixture class that will setup its child fixtures and makes them individually available to your test.
I am still resisting the urge to extract a common pattern for composing fixtures and make a test framework support this.
To come back to the suggestion to use data to drive specifications, I think it is a valid and useful patterns, I usually make the data drive my fixture creation (the fixture has an appropriate constructor for data injection then). See SubSpec's Theorie feature for details.
This answer is 8 years too late, but Gherkin has a way of eliminating this duplication. It's called the Scenario Background:
Feature: ...
In order to ...
As a ...
I want to ...
Background:
Given common step 1
And common step 2
Scenario: A
When ...
Then ...
Scenario: B
When ...
Then ...
More specifically applied to your situation:
Feature: Linking facts from a report into Excel document
In order to link facts to an Excel document
As an user having access to report
I want to click on fact's value in the report
Background:
Given I am logged as admin with admin
And I have selected Sample Project
And I have chosen to view report presentation view containing data from factcollection1 and all periods and all clients
Scenario: Any uri item
When I click on excel cell C2
And I click on the value in 2 column of the row entitled any uri item
Then Excel cell C2 should contain value some internet address
Scenario: Base64 binary item
When I click on excel cell F3
And I click on the value in 2 column of the row entitled base64 binary item
Then Excel cell F3 should contain value asdf
Scenario: Boolean item
When I click on excel cell J3
And I click on the value in 2 column of the row entitled boolean item
Then Excel cell J3 should contain value true
The three common Given steps are moved into the Background, and then each of your scenarios start out with a When.
Nice and tidy.
The reason this is preferable to a scenario outline is because you are dealing with parsing multiple kinds of data. Presumably there is some parsing logic behind the scenes, and parsing each data type could break in different ways during regression testing. Each test should only have one reason to fail, and your original scenarios properly capture that.

Resources