Using Excel IF statement with drop down list - if-statement

I have a fairly simple problem but can't find a solution:
I have a table with a cell that has a drop down function. The user select from that list and I want the next next cell to also be a drop down list but is dependant upon the data in the first drop down
for example
Cell A2 user selects from:
Leeds
London
Liverpool
In B2 the options are now restricted depending upon the data in A2
E.G - Selecting Leeds, returns second drop down of 1,2,3 or 4
Selecting London returns A, B, C, D
Selecting Liverpool returns Cat, Dog, Rabbit
I was looking to use Vlookup tables with an If Statement such as
=if (A2=Leeds(VLookup, C1:C4,2)
However I am hitting an impasse.
Thanks in advance

You can do this by creating named ranges (Ctrl+F3) with the precise name of the look up, e.g the group Cat, Dog, Rabbit you call Liverpool, then in cell B" in data validation select lists and for the source enter
=indirect(A2)
Please note you cannot use spaces with Named Range names so you can replace with underscores if need be.

Related

How to make Index & Match functions on GG Sheets match blank cells?

I have one table of data (A) with data values, and a second table (B) which serves as a key that categorises/groups those entries into categories.
I am trying to write a cell formula that will list the category that corresponds to the data value in (A).
Some of the entries in the data table are empty, i.e. have no input data.
Case in point:
A13 has an empty cell, according to table (B), I specifically want the blank cell to be categorised as "Other". At the moment the sheet thinks cells like these are "null" and not "blank" and therefore returns #N/A.
I have tried adding an IFERROR function, which works at this stage but does not suit the scenario where a new data entry is entered as that will initially show as "Other" too when it should be something else, so I want to avoid using:
=IFERROR(INDEX(D2:D13,MATCH(A2:A13,E2:E13,0)),"Other")
Current cell formula for col B:
=INDEX(D2:D13,MATCH(A2:A13,E2:E13,0))
Please can you help? I've found plenty of articles on how to ignore blank/empty cells, but nothing to include them.
Many thanks!
OH
Shared link of problem
Screenshot of problem
use ifna like:
=IFNA(INDEX(D2:D13, MATCH(A2:A13, E2:E13, 0)))
update:
=INDEX(IF(A2:A13="",,IFERROR(INDEX(D2:D13,MATCH(A2:A13,E2:E13,0)),"Other")))

Sheets, conditional formatting

I am looking to create a conditional formatting function that will highlight "C2:E2" if "E2" > 5000 & "B2" does not contain the word "treasury".
any help would be appreciated!
try on range C2:E:
=($E2>5000)*(NOT(REGEXMATCH(LOWER($B2), "treasury")))
Navigate in top menu to Format -> Conditional formatting
There you can specify range as E2:E29
Use conditional formatting with just one AND formula that refers dynamically to the values of the same row, but different column
AND comparision of the current value
=AND(indirect(address(row();column()-3))<>"Treasury";indirect(address(row();column()))>5000)
This can maybe be simplified, but definitely works with more conditions at once.
Some explanation:
To avoid typing new formulas for each row, we use INDIRECT joined with ADDRESS
column()-3 refers to current column (the one you call formula in) . Have in mind that means for each columns (C->E) you need a different formula that refers to another column for checking if it contains "treasury". In your case you'll need different formulas for column C,D and E. column()-3 works for E, because Treasury is in B column (3 columns earlier from E)
P.S: translating from my native language, so not sure if English UI is the same, but should be intuitive from here.
You'll want a custom Conditional Formatting Rule.
Click in cell C2, then from the menu choose:
Format > Conditional formatting
In the dialog box, set your range:
C2:E29 (or change 29 to whichever row is the last one you want to include in the formatting rule)
Under Format rules > Format cells if..., choose the bottom option from the dropdown menu: "Custom formula is."
In the field below, enter this formula:
=AND(NOT(ISNUMBER(SEARCH("treasury",$B2))),$E2>=5000)
Set your formatting style and click Done.

How to select multiple values from a filter in Google Sheets?

I've got lots of data in a Google sheet (I do not have Excel or Windows as I am on a Chromebook) and I want to use one column to filter out cells which contain two different words. The column of data might contain various values.
Example
Cell 1 Acme - Main - Location
Cell 2 Acme - Secondary - Location
Cell 3 Acme - Location - Main
Sticking with the above example, I would like to use my data filters set at the column headers to only show me cells where it matches Acme and Main.
What is the best way of doing this, please?
I tried using the Text Contains option in the data filter but I'm not sure how to insert both words as something to filter by, it seems to only filter the words exactly how they are typed. So if I type in Acme Main into the filter it will work for some cells which are in that exact order.
if the order of "acme main" combo does not matter you could use:
=REGEXMATCH(A1:A, "Acme(.+)Main|Main(.+)Acme")
if you also want it by any chance case-insensitive use:
=REGEXMATCH(LOWER(A1:A), "acme(.+)main|main(.+)acme")
In the filter options, use this custom formula
=regexmatch(A1:A, "Acme(.+)Main")
and see if that works?
Change column reference to suit.

How to select columns in Hive SQL with the same prefix (beginning) or suffix (ending) or key word in the middle (including)

EDIT 1: Note, I know some of us will question why not list different parts of information in different attributes, so that I will have a relational database to query. The real case is not like the example I am listing below, the variable names are just used here for convenience.
EDIT 2: To reduce the confusion of database design, I change the variable names in the example.
In Hive query, I am looking for a way to select columns with the same prefix, or the same suffix, or including the same key word in the middle of the variable names from the same table.
Here is an example: I have a list of variables like this:
a_A_1, a_A_2, a_B_1, a_B_2,
b_A_1, b_A_2, b_B_1, b_B_2
Exercise 1
I want to select all the attributes starting with 'a'.
Exercise 2
I want to select all the attributes ending with '1'.
Exercise 3
I want to select all the attributes including 'B'.
Much thanks in advance!
Luckily I found a way to do so and I hope it can benefit many others who are looking for the same answer.
First of all, you need to run this setting in your Hive environment:
set hive.support.quoted.identifiers=none;
See solutions below
Exercise 1
select `a.*` from test_table;
Exercise 2
select `.*1$` from test_table;
Exercise 3
select `.*B.*` from test_table;

How to put formula in Data Validation List Excel?

I am creating an excel sheet with following Data Validation drop down list.
NA
Done
(add some formula here)
Basically, i will be able to select either plain text "NA"/ "Done" from the dropdown list. But sometimes, I want the user to be able to calculate some values based on the cell respective to the row selected so, I want to have one formula as a choice inside the data validation dropdown list. Is this possible?
Data Validation List Source
When I click on Formulae option, it should execute the formula with respect to the cells in that Row
But currently, the formula that i put in doesn't execute, instead it will just show the whole formula in the cell when activated.
1)How can i make it so that when i select the formula from data validation list, it will execute it instead of filling up the cell with it?
2)How do i set the formula so that it will be using the cell from the current Row? (for example, if i am using the data validation List in N60, the formula should adapt itself to use the cell (let's say A60?).
I may not be able to help with the second part, but I was seeking an answer to the first and discovered a solution/workaround using Name Manager.
First, in Formula > Name Manager, create a new reference (the "refers to" will contain whatever formula you are wishing to ultimately display in the validation list. For this example, we use the formula reference "=IF($H54=..." and Name it "UniqueName"
Now, we go into Data Validation, Select List, and input the three items we want displayed in the list, with an equals sign preceding our newly named reference: ie. "NA,Done,=UniqueName"
Note: You can't start with the =UniqueName or validation will try to read it all as a formula and fail.
This method will allow the user to display "NA", "Done", or "=UniqueName" in the cell; if "=UniqueName" is selected, the cell itself will interpret this as a formula and execute it accordingly, displaying the results of "=IF($H54=...", or whateverelse you have designated to use as a named formula.
If it's too late for yours, I hope this helps someone else who may face a similar problem.
While I think I know what you're trying to say. Why don't you just use an IF formula to evaluate everything instead of selecting a drop down for every row manually. You already had it partially solved using IF. Just need to add the criteria for a "Done" and an "NA"
=if(A1="date","Done",if(A1<"date","NA",if(something else until you have all your catergories))
Just going to piggyback off of Mark's response.
If you really needed your named formula to be the first selection in the list, you can setup your list with a leading comma like so:
,=UniqueName,NA,Done
That worked out for my use, and there was no null item listed in the Data Validation drop down. Hope that helps!