Verifying multiple string match from range of cells - google-sheets

I am using google sheets. My sheet is for scheduling students. There are multiple teachers that teach a subject each hour, and I want to validate a student's schedule by ensuring they have each of the four required classes preset. Math, ELA, Science, and Social Studies. As the example below shows, the scheduler chooses from a drop down list of available classes for each hour. The cell contains the teacher's name and the subject taught. The Validation cell should search across the row for each of the four partial strings "ELA", "Math", "Science", "Social Stud" and return "Good" if all four are present, or "Error" if there is a duplicate, or one missing. Any ideas?

If there is any chance you might change your strings (Math, ELA, etc), I would recommend declaring them as named ranges, and then you wouldn't have to change all the formulas if you change your strings.
I created an example sheet here:
https://docs.google.com/spreadsheets/d/1P9VjIWLQBm9D75caNI1GH4US9buubPj7LpKFe8vLw2M/edit?usp=sharing
Here's the formula I used (though it performs the same basic function as your accepted answer without requiring wildcards):
=if(isnumber(sum(SEARCH(string1,join(" ",B2:E2)),SEARCH(string2,join(" ",B2:E2)),SEARCH(string3,join(" ",B2:E2)),SEARCH(string4,join(" ",B2:E2)))),Good,Bad)
I'm using named ranges for the valid or error responses as well ("Good" & "Bad"). Again, named ranges allow you to change the string on your "Variables" sheet without having to alter the formulas in your Validation cells

You could simply use AND in a IF condition
=if(
AND(
countif(A3:F3,"*ELA")=1,
countif(A3:F3,"*Math")=1,
countif(A3:F3,"*Social")=1,
countif(A3:F3,"*Science")=1,
),
"Good",
"Error")
if you have other validation you can add it to the AND or even add a AND/OR confition inside a condition

Related

Google Sheets: Search for matching text within two columns across multiple sheets and return sheet title upon correct match?

Example here.
Hi, I'm new to using formulas in sheets so I apologize for what is most likely a common question, but I haven't been able to find a solution that works for me.
Basically, I have a master sheet filled with the names of various institutions in column B, groups of these institutions belong to different clusters as indicated in the additional sheets of the example I've posted. I need a way so that when the institution's names match, they append either the sheet name or simply the string "Cluster 01", "Cluster 02", etc. to column A. Also, if there are no matches to be found, I'd like it to return as a blank cell.
Thanks in advance!
I previously tried
=if(VLOOKUP('Cluster 01'!B4:B6,B4:B13,1,FALSE),"Cluster 01")
But this isn't exactly what I'm looking for, nor does it work.
You can try with XLOOKUP:
=INDEX(XLOOKUP(B2:B,{'Cluster 01'!B:B;'Cluster 02'!B:B},{'Cluster 01'!A:A;'Cluster 02'!A:A},,0))

Advanced filter/configurator based on dataset

I would like help with a problem, or rather a challenge in Excel and/or Google Sheets.
What we want to develop is as follows:
We have a table of products and certain attributes. Now we want to create a kind of search function based on this table.
Example:
Let me give a simple example. Suppose you have as a product an apple, a banana and an orange. The characteristics associated with these are size, color country of origin. We then want a search function, where you indicate one or more preferences, i.e. size, color and/or country of origin and that based on those criteria, all products that meet these criteria are displayed.
So if you specify oblong as the size and do not specify any other criteria, it only shows "Banana. If the banana and the orange have Holland as their country of origin and you only give Holland as the criteria country of origin, it will show 'Banana' and 'Orange'. If you say country of origin Netherlands and format oblong, it again shows only 'Banana'
See below an image of our document and how we would like this to look approximately.
Currently, there is no existing formula, because we simply do not know if this can be done and how best to do it.
The document can be accessed at:
A copy of our document with sample data:
Document
ADDITION:
Hi, Unfortunately I still am not able to get it to work. I am not really a hero in coding/functions. I created a bit more of a clear view in my file and also set the language of my sample file to english. You can find it here: Sample
What I actually need is just that it shows the data on 'Datasheet' if conditions on the left (parameters/value) are met, but only if they are filled. Probably easy one for you, hard to me haha Could you help me out once more? –
Your question is very generic, I will try provide here some guidelines on how to achieve it in Excel or Google Sheet based on my own experience. The approach used for Excel can be used for Google Spreadsheet, since it is based on FILTER function that both tools have but with different signature. For Google Spreadsheet you can also use QUERY that is very powerful for situation like this.
In all cases, it is a good practice to have a sheet with the input raw data (let's say Input tab), then in second sheet the working data of filtered data (let's say WorkData). This is specially relevant when the raw data is big dataset, so you don't touch the original data set, and instead you have the filtered data in a separated tab.
Both tools offer filter features in the UI or slice. This is something to consider, but using Excel/Google Spreadsheet functions, you can show the filter parameters in a more friendly manner, because you can see the parameters selected without additional click to find what filter values where selected. The approach here is based on Excel/Google Spreadsheet functions.
Excel
Let's say you have a block of filter conditions that you want to apply to a range of data. You can use data validation list so you can select a subset of possible values for each of the filter conditions and then to concatenate such conditions logically (OR or AND) using multiplication of addition.
=FILTER(dataset, condition1 * condition2...conditionN)
where each condition is based on the filter value you want to restrict and each condition represents an array of {TRUE,FALSE} values all of them of the same size as dataset (number of rows).
I use some wildcard values to represent all values of the column, in my case I use ALL, but you can setup in a different way. In such case the filter doesn't take effect, but we want to make it work when a specific value is selected. The following trick can be used for both scenarios.
IF(B3="ALL", D3:D15<>"*",D3:D15=B3)
indicating that if B3 is equal to ALL, then the condition to select all of the D3:D15 rows is the following: <>"*". Otherwise select only the rows equals to B3.
Sometimes I would like to consider OR conditions for a given filter condition, for example for a given filter condition, consider value1 or value2 and it is represented in the filter value as a list of values delimited by comma, for example: value1, value2.
Here, some Stack Overflow questions I posted with answers about how to deal with that:
Filter an excel range based on multiple dynamic filter conditions
Filter an excel range based on multiple dynamic filter conditions (with column values delimited)
Google Spreadsheet
The FILTER function here, allows to add the filter conditions via input arguments, so now we have:
=FILTER(dataset, condition1, condition2...,conditionN)
Note: Keep in mind in Google Spreadsheet we don't need to add the conditions by multiplying each one of them. It is added via input argument.
here you can check some of question I posted related to this topic:
Using ARRAYFORMULA with SUMIF for multiple conditions combined with a wildcard to select all values for a given condition
Using ARRAYFORMULA with SUMIF for multiple conditions combined with conditions using a wildcard. Result by Months
In some cases it is better to use QUERY function.
Here, a sample file using QUERY statement and how to combine multiple conditions inserting IF in the where statement.
sample query on C1 cell:
=query('Jira Issues'!$A:$T, "where "
& IF(B2="", "G is not Null", "G >= date '"
& TEXT(startPeriod,"yyyy-mm-dd")&"'")
& IF(B3="", "", " and G <= date '"
& TEXT(endPeriod,"yyyy-mm-dd")&"'")
& IF(OR(B4="ALL",B4=""), "", " and A='"&B4&"'")
& IF(OR(B5="ALL",B5=""), "", " and I='"&B5&"'")
& " label A 'Team', S 'Reporter', T 'Assignee',
P 'Env.', I 'Release'",1)
The raw data is in Jira Issues tab, the data populated is based on multiple filter conditions. I am using some name ranges for the filter values for a better understanding of the formula, such as: startPeriod, endPeriod, etc. You can test the actual query will be invoked looking at the result of the consolidated string of the query input argument of QUERY function.
Similarly you can stablish a where statement to consider whether the input parameter is empty or not. In such case, you can build a logic like this inserting an IF block as part of the where statement and concatenate the string result.
=QUERY(Input!A:Y,
"select *" & " where A " & IF(B2="", "<>'*'", "='"&B2&"'")
"and " & " where B " & IF(B3="", "<>'*'", "='"&B3&"'")
,1)
The above query for column A or B, returns the entire column via condition: "<>'*'" if the input parameter B2 or B3 were not specified. In a similar way you can add additional conditions for more parameters, repeating the third line of the query and changing the column and the parameter cell.
Recommendations
Focus on a specific tool: Excel or Google Spreadsheet, even they have some similarities, you need to get familiar with the specifics of each one of them.
Try to start working on your specific problem, once you face impediments, do some research, usually you are not the first person facing this problem, if you don't find a solution, then post your specific problem using a sample as an extract of your real problem (in English, your sample is in other language). Generic questions like this one are difficult to get some attention.

Google Sheets Count Unique Dates based upon a criteria in different columns

I am trying to find a formula that will give me the count of unique dates a persons' name appears in one of two different columns and/or both columns.
I have a set of data where a person's name may show up in a "driver" column or a "helper" column, multiple times over the course of one day. Throughout the day some drivers might also be helpers and some days a driver may come in for duty but only as a helper. Basically all drivers can be helpers, but not all helpers can be drivers.
I've attached a link to a sample sheet for more clarity.
https://docs.google.com/spreadsheets/d/1GqNa1hrViX4B6mkL3wWcqEsy87gmdw77DhkhIaswLyI/edit?usp=sharing
I've created a REPORTS tab with a SORT(UNIQUE(FLATTEN)) Formula to give me a list of the names that appear in the DATA Tab.
I'm looking for a way to count the unique dates a name from the name (Column A of the REPORTS Tab) appears in either of the two columns (Column B and/or C of the DATA Tab) to determine the total number of days worked so I can calculate the total number of days off over the range queried.
I've tried several iterations of countif, countunique, and countuniqueifs but cannot seem to find a way to return the correct values.
Any advice on how to make this work would be appreciated.
I think if you put this formula in cell b7 you'll be set. You can drag it down.
=Counta(Unique(filter(DATA!A:A,(DATA!C:C=A7)+(DATA!B:B=A7))))
Here's a working version of your file.
For anyone interested, Google Sheets' Filter function differs slightly from Excel's Filter function because Sheets attempts to make it easier for users to apply multiple conditions by simply separating each parameter with a comma. Example: =filter(A:A,A:A<>"",B:B<>"bad result") will provide different results between the Sheets and Excel.
Excel Filter requires users to specify multiple conditions within parenthesis and denote each criterion be flagged with an OR condition with a + else an AND condition with a multiplication sign *. While this can appear daunting and bizarre to multiply arrays that have text in it, it allows for more flexibility.
To Google's credit, if one follows the required Excel Syntax (as I did in this answer) then the functions will behave the same.
delete what you got and use:
=QUERY(QUERY(UNIQUE({DATA!A:B; DATA!A:A, DATA!C:C}),
"select Col2,count(Col1),"&D2&"-count(Col2)
where Col2 is not null
group by Col2"),
"offset 1", 0)

List or auto-complete existing string values, for new plaintext cell

I have a plaintext column in my Google spreadsheet, several rows (cells) of which have already been filled with a limited number of strings, let's say for simplicity "January", "February", "March", etc.
I would like to format the column such that, when entering text in new (empty) cells, rather than having to type the text from scratch, I instead get to choose from a drop-down list populated with the strings that already exist in other cells of that column (all 12 months, in the example above).
Or, alternatively, to have an auto-complete that would suggest, say, "March" and "May", once I start typing "M". Strangely, I haven't seen this basic feature at work in GSheets for a while, even though the EnableAutocomplete option is checked in the menu.
Among the two options, I would prefer the one with the drop-down list over the autocomplete one, but ultimately either would be of massive help. The idea is, once the number of unique strings becomes high (but there is also a lot of repetition), to reduce the chance of making a typo when entering new values just because they happen to differ by one letter from a string that already exists elsewhere.
Is there a way to do this just via the GUI/addons? I know this is possible to do in Excel for the header row (screenshot below), but I don't know of a way to do that also in GSheets, and in either case, what I need is to have this sort of selection list at the cell- rather than at the header-row level.
what you are looking for is called Data Validation:
and you can select various options for criteria

How to auto populate specific Google Form fields, based on dropdown choice

I use Google Forms regularly at work, and I think they are awesome, especially since I am a total newbie with coding. With a few good plugins for Forms and Sheets, I am able to generate contracts, invoices, and so on very easily, based on document templates.
To keep it short, here is my request:
I have a form, where I input the customer's details, and upon submission, an addon generates a gdoc, based on a template. Al working great so far. My problem is that we are generating many different documents for a single customer, so it becomes a repetitive and very time-consuming task, considering that I have 15-20 different input fields for a customer, plus specific input fields for each different document.
The first input filed in my form is "Customer Name" and I have managed to create a dynamic dropdown list, that takes it's information from a specific column in a Google Sheet.
My request: how could I auto populate specific input fields in my Google Form, so that, based on my dropdown choice, the auto completed information will match the corresponding row present in the Google Sheet.
I have attached 2 images for easier understanding:
You can actually do this with a simple vlookup:
note: I also always wrap my functions with and if statement that checks if there is text in the first field, so try:
pretend that your dynamic customer name is in cell A1:
customer vat formula -
=IF(ISTEXT(A1),VLOOKUP(A1,'Parteneri'!A:C,2,FALSE),)
customer city formula -
=IF(ISTEXT(A1),VLOOKUP(A1,'Parteneri'!A:C,3,FALSE),)

Resources