Data Validation cell lock if value is true (Google Spreadsheet) - google-sheets

I am currently working now on creating data validation in google spreadsheet, and I want to lock a certain cell based on the value of the other cell in another spreadsheet.
Scenario: (Based on the Image)
There are 2 different spreadsheets (Sample1 & Sample 2) with has the same column H which is Status and the same Cell H2 which is Dropdown list (Active and Inactive).
on Sample1 Cell H2, If I choose Inactive, I want the Sample2 Cell H2 to be locked, otherwise if on Sample1 Cell H2 If I choose Active, the Sample2 Cell H2 should be remain as dropdown list.
Thanks in advance.

I assume you don't want to lock the cell as in protecting it.
You can't remove the data validation but you can give it an empty set.
The easiest approach for this kind of thing is to add a Control sheet that handles this.
It may be a bit overkill for this application but you could create proper interactive menus in this fashion that are more complex and contain more options on the dependent and the independent side.
____A_________B_________C____
1| Active| Inactive| Current|
2| Active| | |
3| Inactive| | |
With cell C2 getting the formula
=INDEX(A2:B3, , MATCH(Sample1!H2, A1:B1, 0))
And the Data validation in Sample2!H2 referring to Control!C2:C3

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.

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

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

How to convert address match formulas into dynamic ranges?

I'm trying to develop a formula that sums cells in a column based on a range set dynamically by the addresses of two cells with specific text that change address depending on how many rows are between the two cells.
Example: sheet red_fruit
| A | B | C
1 | Fruit store | |
2 | | apples | 5
3 | | apples | 5
4 | | oranges | 1
5 | Fruit store branches (text) | |
In a second sheet called "summary", using the data from sheet "red_fruit" I want to add the amount of apples in column C based on a range set from row "fruit store" to row "fruit store branches" and ignore the amount of oranges.
However, I do not want to use absolute cell addresses (A1, B2, etc) because I know that the columns between "fruit store" and "fruit store branches" will change in future sheets.
I also need to constrain the C values to the depth of "fruit store branches" because I know that in the future there will be more data after that row.
In the past I have been able to do this with the following formula:
=SUMIF( 'red_fruit'!$B$1:B, "apples*", 'red_fruit'!$C$1:C )
But that only works for absolute values for the B column and it does not have dynamic limits neither for the B column nor for the C column.
So now I need to figure out a way to replace the B values with a dynamic formula that adjusts to automatically if I add more rows between "fruit store" and "fruit store branches".
I was able to get the address for column B dynamically using the following formulas:
For the "fruit store" row:
=ADDRESS((MATCH("fruit store",A1:A,1)),2,4)
The result is B1
For the "fruit store branches" row:
=ADDRESS((MATCH("fruit store branches",A1:A,1)),2,4)
The result iss B5
Here's where I got stuck. I have been unable to mix the formulas to create a dynamic range. The best I have been able to come up with this the following formula, but it returns an error:
=SUMIF( indirect"&(ADDRESS((MATCH("fruit store",A1:A,1)),2,4):"&(ADDRESS((MATCH("fruit store branches",A1:A,1)),2,4) , "apples*", c1:c ))
What I'm looking for would look like this:
=SUMIF( 'red_fruit'!dynamic_cell_address_formula1:'red_fruit'!dynamic_cell_address_formula2 , "apples", 'red_fruit'!$C$1:C )
=sum(filter(red_fruit!C:C,row(red_fruit!C:C)<MATCH("fruit store branches",red_fruit!A1:A,1),red_fruit!B:B="apples"))
I was unable to find a solution to this problem with a single formula, but I was able to solve it using 3 formulas in a transitional sheet.
First, I created a sheet called "AppleData". In AppleData, cell B2, I entered the following formula:
=IFERROR(MATCH("Fruit Store",'red_fruit'!$A$1:$A,0), "")
That would give me the first coordinate for the range from "fruit store" to "fruit store branches". If there is no data, then the IFERROR formula would simply leave the cell blank.
Then, in the cell below, B3, I entered this formula:
=IFERROR(MATCH("*Fruit Store Branches*",'red_fruit'!$A$1:$A,0)-1, B2)
Again, if there was no data, the cell would match cell B2, which would be either blank, or with a valid coordinate number.
Next, in B4, I added a formula that used the contents of cells B2 and B3 to create the range between "Fruit Store" and "Frui Store Branches", look for "apples" and then add the quantities only for the apple entries :
=SUMIF( indirect("red_fruit!A"&AppleData!B2&":A"&AppleData!B3), "*apples*", indirect("red_fruit!C"&AppleData!B2&":C"&AppleData!B3) )
Then I created a similar system for each month of the year, as each month I would get a new spreadsheet with different data to sort and plug into a summary sheet.
So now all I have to do is go to a summary sheet and add up the "B4" cells, thus solving the problem of creating dynamic ranges for this scenario.
Personally, I would've prefer to use a single formula in the summary sheet, but since this also works and it solves the same problem, I can live with it.
Thanks to those of you who gave it a sincere shot at solving this problem.
This does what you want =)
=SUMIFS(
OFFSET(red_fruit!$A$1,
MATCH("Fruit Store",red_fruit!$A:$A,),2,
MATCH("Fruit store branches (text)",red_fruit!$A:$A,),1),
OFFSET(red_fruit!$A$1,MATCH("Fruit Store",red_fruit!$A:$A,),1,
MATCH("Fruit store branches (text)",red_fruit!$A:$A,),1),"apples")

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