How can I filter my search in a column on google sheet which collects data from a form? - google-sheets

I would like to perform a multi criteria search of data in a column- contains data of check boxes(more than one option chosen).
For a clearer picture of what I am trying to do, screenshot below is a question in a form
Data from the form are saved in sheets like below,
So my concern here is if I would like to search/filter for the rows that contain "Commercial", the rows with Commercial,Engineering doesn't show up. That's definitely not an effective search.
Any advise on how can I go about this issue is kindly appreciated. If

Let's say you have your form in the response sheet in columns A to P, with the multiple choice in col D. If you want to filter your data on the word 'Commercial' you can either do:
=filter(A2:P, regexmatch(A2:P, "Commercial"))
or use query():
=query(A2:P, "select * where B contains 'Commercial' ")
Note: depending on your locale you may have to change the commas to semi-colons in order for the formulas to work.
I hope that helps ?

Following JPV's answer, I developed a line to make the query useful if you want to cross two categories. Let's suppose that someone in your checkbox example had picked all the options (IT, HR, Commercial, Engineering); and that you have created the cell with the dropdown option box in cell B1 with all your options, as JPV said.
Then, you want to filter and see all the people who had chosen IT and Commercial. You would, for that, create a second cell with the dropdown option box in, lets say C1; and then your query would be:
=query(A2:P, "select * where B contains '"&B1&"' and B contains '"&C1&"' ")

=FILTER(MOBILE!A2:E2000, ISNUMBER(SEARCH(A1,MOBILE!A2:A2000)))
SEARCH function will return a number of the position of the searched word (A1) in the searched strings in range (MOBILE!A2:A2000).
If the result of search is a number (ISNUMBER), then filter will return the TRUE rows result from the range MOBILE!A2:E2000.

Related

How can I exclude a row from a formula based on a value of one cell in it in Google Sheets

I am working on a spreadsheet for a project that involves listing five ingredients for a recipe, along with a number value of how many of that ingredient is needed. I am then using functions in Google Sheets to automatically create a list of all unique ingredients and how many there are across all rows, broadly seen here:
enter image description here
For the "Ingredient List" I am using the code:
=SORT(UNIQUE(FILTER(FLATTEN(E4:E, G4:G, I4:I, K4:K, M4:M), FLATTEN(E4:E, G4:G, I4:I, K4:K, M4:M)<>"")))
And for the "#" column to the right of it I am using the code:
=IFERROR(SUM(FILTER($F$4:$F,O4=$E$4:$E)))+IFERROR(SUM(FILTER($H$4:$H,O4=$G$4:$G)))+IFERROR(SUM(FILTER($J$4:$J,O4=$I$4:$I)))+IFERROR(SUM(FILTER($L$4:$L,O4=$K$4:$K)))+IFERROR(SUM(FILTER($N$4:$N,O4=$M$4:$M)))
What I would like to do is to make so that if the value in column D ("Obtained?") is "Yes", then the entire row (E-N) is excluded from the two lists in columns O and P, but I do not want anything to be deleted. This would allow me to depopulate the "Ingredient List" as additional rows are marked "Yes", theoretically until a point where it is empty.
Is this something I can plausibly do using the tools within Google Sheets, and if so, how? Thank you!
I've tried some variations of "If" or "Ifs", but I need it to check every cell in one column from one cell (O4 and P4).
Can you try this in Cell O4. you may need to clear the exsiting formula(s) in columns O & P to let this formula freely expand.
=let(a,filter(E4:N,D4:D="No"),b,tocol(choosecols(a,1,3,5,7,9),1),c,tocol(choosecols(a,2,4,6,8,10),1),byrow(unique(b),lambda(z,{z,sum(filter(c,b=z))})))

Unnest two columns in google sheet

I have a table like this one here (basically it's data from a google form with multiple choice answers in column A and B and non-muliple choice data in column C) I need a separate row for each multiple choice answer.
Column A
Column B
Email
A,B
XX,YY
1#gmail.com
A,C
FF,DD
2#gmail.com
I tried to un-nest the first column and keep the remaining columns like this
enter image description here
I tried several approaches I found with flatten and split with array formulas but I don't know where to start really.
Any help or hint would be much appreciated!
You can use the split function on the column A and after that, use the index function. Considering the table, you can use:
=index(split(A2,","),1,1)
The split function separate the text using the delimiter indicated, returning an array with 1 line and 2 columns; the index function will return the first line and the first column from this array. To return the second element from the column A, just change to
=index(split(A2,","),1,2)
I think there's no easy solution for this. You're asking for as many combinations of elements as multiple-choice elections have been made. Any function in Google Sheets has its potentials and limitations about how many elements it can express. One very useful formula here is REDUCE. With REDUCE and sequences of elements separated by commas counted with COUNTA, you can stablish this formula:
=QUERY(REDUCE({"Col A","Col B","Email"},SEQUENCE(COUNTA(A2:A)),LAMBDA(z,c,{z;LAMBDA(ax,bx,
REDUCE({"","",""},SEQUENCE(ax),LAMBDA(w,a,
{w;
REDUCE({"","",""},SEQUENCE(bx),LAMBDA(y,b,
{y;INDEX(SPLIT(INDEX(A2:A,c),","),,a),INDEX(SPLIT(INDEX(B2:B,c),","),,b),INDEX(C2:C,c)}
))})))
(COUNTA(SPLIT(INDEX(A2:A,c),",")),COUNTA(SPLIT(INDEX(B2:B,c),",")))})),
"Where Col1 is not null",1)
Since I had to use a "initial value" in every REDUCE, I then used QUERY to filter the empty values:

SUMIFS and ARRAYFORMULA within Google Sheets

I have a google sheet with multiple tabs, one of the tabs is for holding each observation of data while another needs to combine data based on certain criteria. I am trying to use a SUMIFS within and ARRAYFORMULA to get the correct information and it will only pull "0" no matter what I try.
I have set up a test google sheet with some dummy information to show an example of what I need to do in a more complex situation.
https://docs.google.com/spreadsheets/d/1JLyEuVijQ8MvfOKrtbRD_YKmRDnTCxf7qCSw9Ggty_Y/edit#gid=1250575550
In this example, the data tab is the individual observations and the sums tab is where I'm trying to pull combinations. I need column D to sum the totals in column E on the data tab if the Month and Year and Type all match what is on the sums sheet. In this example, cell D3 on the sums tab should equal 11.
you cannot use SUMIFS() in Arrayformula(), along with many other functions, though there is no formal documented list.
In your case you can use a SUMIF() instead by &'ing the condtions together.
I've demoed the concept on a new tab called MK_Help in cell D2:
=ARRAYFORMULA(IF(ROW(A2:A) = ROW(A2), "# TOTAL TYPE", IF(A2:A = "", , SUMIF(data!A:A&data!B:B&data!C:C,A2:A&B2:B&C2:C,data!E:E))))
Note that I made a couple of other small changes to your formula.
Namely, that you should always use a true "empty" instead of double quotes in your IF() mask up front tor return empty when there's no value in A. Double quotes("") is actually not quite empty for many other things in Google sheets.
Also I modified your header conndition from ROW(A2:A)=2 to ROW(A2:A) = ROW(A2). I find that this is a more flexible condition for the header as it allows you to potentially insert/delete rows above the header without breaking things.
It seems QUERY() may be good choice. Try-
=QUERY(data!A2:E,"select A,B,C, sum(E) where A is not null group by A,B,C",1)
If you need specific month then you can add criteria to where clause like-
=QUERY(data!A2:E,"select A,B,C, sum(E) where A =5 group by A,B,C",1)

Manual data tagging and lookup

I need a system that allows to filters entries by different text tags.
Say we store info about some products. We have Red Apples, Pears, Watermelons, Cucumbers, Peppers and Bread. We store them in sheet named "Data" in column A. Next columns are occupied by tags, like Red Apples are Red, Sweet, Fruit, Unpacked; Peppers are Red, Spicy, Veggie, Packed; Bread is just Packed.
Then on another sheet we have a dedicated range, say A1:A10, which can accept any data tag, like Spicy or Packed. What I need is when somebody enters Spicy and Packed in this range, it looks up all items that are Spicy and Packed and displays them, so in this case it would display Peppers in B1 cell.
To recap: Data!A:A - entry names, Data!B:Z - tags, Main!A1:A10 - tags entered by user, Main!B:B - entries with tags, that correspond to those entered in A1:A10.
I was trying to use FILTER, but I can't figure out how to select proper condition ranges. I feel like this should be possible within this system and I really don't want to delve into scripting field.
This can be achieved using a helper column to collect all the tags and then a =query() formula.
1)
Start by creating a multi-tag column using either =join() or =textjoin(), capturing all the potential tags for each product.
2)
Then use this answer to help you create the =query() formula needed.
There is a pretty simple solution to this.
You would need to add a helper column and count how many tags does your item has from the listed ones, using this formula
=SUM(ARRAYFORMULA(COUNTIF(B1:1,'Main'!$A$1:$A$10)))
Next, in your presentation sheet reserve some place where you can enter tags - one at a time. In my case, it's range A1:A10. Then just paste this formula anywhere else
=IFERROR(FILTER(Data!$B:$B,Data!$A:$A=(10-COUNTBLANK($A$1:$A$10))),"")
At that place, all suitable elements will show up. I also added sorting to the formula, cause why not.
You can use more tags, for that just increase the tag range and edit formula so when there are no tags entered, COUNTIF gives 0.
if Data sheet looks like this:
and you need "constructive" list, you can do:
=SORT(FILTER(Data!A2:A, REGEXMATCH(TRANSPOSE(QUERY(TRANSPOSE(Data!B2:Z),,999^99)),
TEXTJOIN("|", 1, A1:A10))))
spreadsheet demo
if you need a "destructive" list do:
=ARRAYFORMULA(SORT(QUERY({Data!A2:A, TRANSPOSE(QUERY(TRANSPOSE(Data!B2:Z),,999^99))},
"select Col1 where "&TEXTJOIN(" and ", 1, IF(A1:A10<>"",
"Col2 contains '"&A1:A10&"'", ))&"", 0)))

Google Sheets: selecting cell values based on another cell MAX values

I'm trying to make a database of students using Google Sheets. It contains info about students, groups and orders; orders can change students membership in groups (taken in a group, moved up to a new group, graduated, on leave, sent down). Here are sample database sheets and here is a detailed description of my DB structure (the sheet report_Groups is slightly changed, its previous variant, described on the link, is now named old_report_Groups).
I need a query that would select a list of present members of given group on the given date. That means that for each student I have to select
the name, the latter status before given date and corresponding group. And from this result select student names, where statuses are "Taken in" or "Moved Up" and group is the same as given one.
The problem is to select the latter status. It should be MAX(status), whose "since" date ≤ given date, but there's a well-known problem of selecting more than one field together with aggregate function. Here is a question which is very close to, but query from its "best" answer gives me error "QUERY:NO_COLUMN". I've even copied the sheet Raw from there and tried to perform proposed query (with the onliest modification — replacing commas with semicolons according to my locale restrictions) on the data it was reported to work on — same error (check Raw and report_Raw sheets in my DB). Other variant (via MMULT and TRANSPOSE) works, but it's perfomance is very poor.
What can you suggest me? Thanks in advance.
Update: I've found the solution with an issue (described in my answer).
To solve the issue I need to know an answer for a different question.
Here's the solution (with an issue described below).
A. Orders_Students is filtered for selecting rows, having "since" cell value ≤ given date (report_Groups!A2):
=QUERY(Orders_Students!B:E;"select E, B, C, D where E <= date '" & TEXT(report_Groups!A2;"yyyy-MM-dd") & "'";1)
This interim result is stored at the inner_report_Groups tab (it will be referenced few times in the next query).
B. inner_report_Groups is filtered for selecting MAX("since") values and corresponding row cell values for each student:
ARRAYFORMULA(VLOOKUP(QUERY({ROW(inner_report_Groups!A$2:A)\SORT(inner_report_Groups!A$2:D)};"select max(Col1) group by Col3 label max(Col1)''";0);{ROW(inner_report_Groups!A$2:A)\SORT(inner_report_Groups!A$2:D)};{3\4\5};0)
The formula above is used as inner query in report_Groups!D2 (also in D3, D4—with appropriate indeces).
C. The second query result is filtered to get students whose status is either "Taken in" or "Moved Up" and corresponding group is equal to the given group (report_Groups!B2 (also in B3, B4—with appropriate indeces)):
=TRANSPOSE(IFERROR(QUERY(<here is the formula from step B>);"select Col1 where Col3 = '" & B2 & "' and (Col2='Taken in' or Col2='Moved Up')";0)))
The formula above is used as outer query in report_Groups!D2 (also in D3, D4—with appropriate indeces). IFERROR is intended to display nothing if query result is #N/A.
That query displays the needed results as you can see in report_Groups tab. But as the query on step B searches the whole columns of inner_report_Groups, there's only a single given date can be analysed (or the query interim results for other given dates should be placed in different columns of inner_report_Groups or at the different tab. Is there any way to give an alias for an interim result to refer it in a single cell formula instead of keeping it on different tab?

Resources