Google Sheets Query Search Box | Search criteria - google-sheets

so basically I have a searchbox in my sheet that searches and pulls up data. For a reference see this image: https://i.imgur.com/MVTUCSw.png. So basically in cell A4 I put the data that I am looking for, but my formula restricts me to only looking up stuff in 1 row. For example, data starting with the word MELD, but I would like to be able to also look up data based on for example the someone their name.
The formula I use for the searchbox: =QUERY({'Pallets & Locaties'!A2:G;Voorraadverschillen!A2:G}, "SELECT * WHERE Col1 "&Opzoeken!B4&" '"&A4&"'")
The data that I want to be able to look up is stored in 2 sheets: Pallets & Locaties - https://i.imgur.com/qV7h2tz.png and in Voorraadverschillen - https://i.imgur.com/foqLkKa.png.
The searchbox is only able to lookup data in row, but I just want to be able to search for any kind of stored data in any of the sheets.
Here is my sheet for reference: https://docs.google.com/spreadsheets/d/10wmnxV16JUiD_b_54abkiLPwTqLITWRcUw3gsqvXoBE/edit?usp=sharing

I'd recommend you add more rows for the lookup criteria and add a column for what column it would search for.
Sheet modification:
Formula:
=QUERY({'Pallets & Locaties'!A2:G;Voorraadverschillen!A2:G}, "SELECT * WHERE "&TEXTJOIN(" AND ", TRUE, ARRAYFORMULA(IF(ISBLANK(A4:A10), "", A4:A10&" "&B4:B10&" '"&C4:C10&"'"))))
Test Sheet
Note:
The above formula will allow you to search on other columns with their own words and criteria to search.
Only rows with Kolom values will be included in the criteria. If you only need Col1 criteria, make sure to leave other rows blank.
This does use an AND search, meaning all of the criteria should be true and match the row. Feel free to use OR in the TEXTJOIN function if you only want to search all rows matching any of the criteria.
This will only search on sheets Pallets & Locaties and Voorraadverschillen. Add the necessary sheets if you need them.

EDIT:
Cleaned up the formula to not be so repetitive.
=IF(A4<>"",(QUERY({'Pallets & Locaties'!A2:G;Voorraadverschillen!A2:G},"Select * WHERE "&textjoin(" OR ", true, arrayformula("Col"&ROW(1:7)&" "&B4&" '"&A4&"'")))),(QUERY({'Pallets & Locaties'!A2:G;Voorraadverschillen!A2:G},"Select * WHERE Col1 IS NOT NULL")))
This searches every column for the data, as long as data is not identical in two columns you won't have issues. An example would be the search criteria "MELD" being in both Column A and B. If that were the case, only the results from the first matching column would populate.

Related

Importing values of column from other sheet based on a matching values in a different column across both sheets?

Hey Stack Overflow Sheets, I have a question regarding a use case we want to create in our Google Sheet, either with built-in functionality, or with an extension like Sheetgo.
We have 2 sheets with multiple of the same columns (properties) and rows (users). The problem is that only one of the sheets is a trusted source for one column’s data (“source sheet”), and the other sheet has empty or outdated values for the same column (“outdated sheet”), and we need both sheets to have this column match values in rows that have a matching value for another column across both sheets (in our case, an “email” column). After they’re matching, we want to change the formula to sync any changes made for that column between both sheets.
Here’s an obfuscated data example:
Source sheet:
https://docs.google.com/spreadsheets/d/1uxqC3lB15UHhKTzjZyzzVIj5tlPjhCCCZ48xHYEcm0o/edit?usp=sharing
Outdated sheet:
https://docs.google.com/spreadsheets/d/1ckoCh8gMwt2QeBRH1dB2dyFPJUukrjQ-SCgucTL8rhc/edit?usp=sharing
In the example, we’re looking for a formula that would allow us to have a “Type” column value injected into the Outdated Sheet’s Type column, based on both sheet’s matching Email column value. And then, have it so if a row’s “Type” value changes in either doc, the other doc follows.
What formula or extension would I use to go about this? Any help appreciated, thanks!
I tried to create a VLOOKUP and MATCH formula, but I couldn't yet figure out how to have the function first LOOKUP into the Source Sheet, then inject it into the Outdated Sheet based on a matched email column value. Sheetgo made the LOOKUP easier, but I still couldn't figure out how to do an exact operation.
Use importrange() and vlookup(). Put this formula in cell A1 of the target spreadsheet:
=arrayformula(
lambda(
import,
iferror(
vlookup(
C1:C,
{ index(import, 0, 3), index(import, 0, 1) },
2, false
)
)
)(
importrange("1uxqC3lB15UHhKTzjZyzzVIj5tlPjhCCCZ48xHYEcm0o", "Sheet1!A1:F")
)
)

Use dynamic created Query text as a Query formula in Google Sheets [duplicate]

This question already has answers here:
Stacking Multiple Arrays In Query/Lambda Function
(2 answers)
Closed 3 months ago.
First of all this is my first question here...
Ok, and now my problem:
I created a formula that generates a dynamic Query if you are searching for data in multiple sheets. I just write the names of the sheets in green field and it changes the Query.
The text for the Query is correct, but now I want this to by the actual formula in a cell to display the data.
If I use the = and add the cell with the Query text, it copy the text. I tried the INDIRECT formula, but it does the same.
How can I use a this dynamic text to be my Query to dispaly the data depending on the amount of names in the green field?
EDIT: As advised by user doubleunary (as mentioned, this is my first time), I'm going to rephrase the problem.
In an spreadsheet a manager imputs for every task the amount a worker has made. He creates an new sheet for each date and imputs the data for that day. Each day can have different rows of data. The boss wants a spreadsheet that display in one sheet all that has been done in the current month. I used Query because you can easy join data from multiple sheets and ignor the empty rows.
But the problem is, that every day a new sheet is added with a new "name" (date). And the easyest way I found tho make a dynamic Query, without the Boss to manualy edit the Query, was to create a text with TEXTJOIN formula, in witch he ony needs to enter the new "name" (date).
If there is a better was, please share, but it should not be in App Script if possible.
Thank you.
Easily you can't transform a text into a formula.
In this case, you should create the query formula and insert the ranges with Indirect function, like this:
=Query({Importrange(LINK,Indirect("'"&O4&"'!I38:S107"));Importrange(LINK,Indirect("'"&O5&"'!I38:S107"))},"Select * Where Col1 is not null",0)
If the formula you quote and the data sheets are all in the same spreadsheet file, you should not to use importrange() but indirect(), like this:
=query(
{
indirect(O4 & "!I38:S107");
indirect(O5 & "!I38:S107")
},
"where Col1 is not null",
0
)
In the event the row references such as I38:S107 change from time to time as well, you can put those references in a cell and refer to them the same way.
try (assuming url is same for all sheets):
=QUERY(LAMBDA(x, QUERY(REDUCE(SEQUENCE(1, 11), x,
LAMBDA(a, c, {a; IMPORTRANGE("url", c"!I38:S107")})),
"where Col1 is not null", 1))
(O4:INDEX(O:O, MAX((O:O<>"")*ROW(O:O)))), "offset 1", )
more examples: https://stackoverflow.com/a/74280310/5632629

Google sheets question - filter sum equation

I have a list of email addresses in one sheet (first column).
I have a list of transactions in another sheet with emails and sale amounts.
I am looking for a formula that adds up all the transaction $ sales for any transactions made by the people (emails) in the first sheet.
Any help would be much appreciated!
Your sample data is very limited (only one row matching one person, in fact). But the following formula should work for you. Place it in a new sheet, in cell A1:
=ArrayFormula(IFERROR({"Name","Total"; QUERY(FILTER(Transactions!A2:D,NOT(ISERROR(VLOOKUP(Transactions!A2:A,Tags!A:A,1,FALSE)))),"Select Col2, SUM(Col4) GROUP BY Col2 ORDER BY Col2 LABEL SUM(Col4) '' ")},"No Data"))
This one formula will produce the headers (which you can change within the formula itself as desired) and all results.
FILTER filters in only 'Transactions' data (names through amounts) where the emails are found in the 'Tags' sheet.
Then QUERY returns the name and totals for each match in alphabetical order by name.
If there are no matches, "No Data" will show instead.
If I understood your question correctly!
Try this on the sheet, where you only have emails and wanted to get sum of sales amount
=sumifs(range_whichHasTransaction , range_of_Email_inThat_TransactionsTable , Cell_Reference_ofEmail_forWhich_you_want_sum_the_Transaction_Amount)
it will Look something like this:-
sumifs(TransactionSheet!B:B,TransactionSheet!A:A,Emails!A2)
Reference
SUMIFS

Google Sheets Query using important range and a dynamic cell reference

I have a roster of students (Sheet 1) and I need a formula to search another sheet (Sheet 2) to see if each student on Sheet 1 is also on Sheet 2 and if they return the word "yes"/ if they are not I would like the cell to remain blank.
This is the formula I have:
=QUERY(IMPORTRANGE("https://docs.google.com/spreadsheets/d/1395p5J5oN4vYLPeyAdUQDZluwxWU53NYJPiqeHdXSEw/", "Quarter 3!A3:H"), "Select 'yes' where Col1="&$A7&"")
The formula is not working properly.
For students that are on Sheet 2 the formula is returning two rows of data (two rows of "yes) and the first instance of "yes" include characters that I did not include in the query:
For students not on Sheet 2, the formula is returning a yes with the extra characters "yes"().
I feel like I should be using an IF function, but I could not get it to work with IMPORTRANGE
use:
=QUERY(IMPORTRANGE(
"1395p5J5oN4vYLPeyAdUQDZluwxWU53NYJPiqeHdXSEw", "Quarter 3!A3:H"),
"select 'yes' where Col1="&$A7&"
label 'yes''')

Display Rows From Another Sheet Based On Range Of Dates

I'll try to explain this as best as I can, I'm not super experienced with spreadsheet formulas so bear with me.
Currently I have 2 Google spreadsheets, one contains a list of all client related tasks. The second spreadsheet is client specific, it has a few sheets such as "Feeder", "Archived Requests", "Monthly Report". The "Archived Requests" sheet lists all the data assigned to a specific client from my first spreadsheet using QUERY IMPORTRANGE:
=Query(IMPORTRANGE("key","spreadsheet-name!A:Z"),"Select Col2, Col3, Col4, Col5 where Col1 contains 'TOSC'",1)
This part works all fine and good.
My "Feeder" sheet lists some =DATE and =EOMONTH formulas which I have made into Named Ranges.
What I'd like to do, ideally, is display all data from the "Archived Requests" sheet on the "Monthly Report" sheet between the named range "ReportMonthStart" and "PriorMonthStart".
Essentially, what I'm hoping to achieve is a dynamic listing of row data that goes back 30 days from the 15th of each month.
I'm not sure if this should/can be done with a Query or a Filter, or any other formula.
Here is the link to my current spreadsheet.
The filter does this nicely:
=filter('Archived Requests'!A2:E, ('Archived Requests'!A2:A >= PriorMonthStart) * ('Archived Requests'!A2:A <= ReportMonthStart))
This returns A-E entries of the rows where A column is between PriorMonthStart and ReportMonthStart. Multiplication of two conditions is logical AND.

Resources