Show no results if search box is empty using Filter Function on Google Sheets - function

I'm hoping somebody has a quick solution for me. I have a fantasy sport league setup on a google sheet. One of the sheets allows other people to search a database of players. Its broken down into four different search boxs offering the following search options: By Player, Position, Owner or Player designation. I'm using the filter function:
=filter(Sheet242!A2:E,search(B6,Sheet242!A2:A),search(E6,Sheet242!E2:E),search(B8,Sheet242!C2:C),search(E8,Sheet242!B2:B))
It draws from a table on a separate sheet.
This works great with one exception. It returns all the values in my table when all 4 search boxes have no value. I want it to filter no results if all 4 boxes are empty.
Here is a link to my google sheet so you can have a better visual of what im trying to do:
https://docs.google.com/spreadsheets/d/1XlfWyDOi-cEynVCcnWEpbOF7qIm_HlAKk2yG31rYvJw/edit?usp=sharing
The two sheets in question are "Player Database" and "Sheet 242".
Any suggestions would be greatly appreciated!

try:
=IF(LEN(B6&B8&E6&E8)=0,, FILTER(Sheet242!A2:E,
SEARCH(B6, Sheet242!A2:A), SEARCH(E6, Sheet242!E2:E),
SEARCH(B8, Sheet242!C2:C), SEARCH(E8, Sheet242!B2:B)))

Related

Google Spreadsheets ArrayFormula: How to split and transpose a cell-range?

Hello everybody and thanks a lot for your help.
Here's my problem:
What I have:
I have a table with raw data in 53 rows and numerous columns which I would like to reduce and restructure into three columns: City, Date and Value.
https://docs.google.com/spreadsheets/d/1bsdC8lrtSGk957ae8Z0VRGnDqTZfFLPpLkfoid0UbIQ/edit?usp=sharing
What I've done so far:
For a single row, I used the following formula to make everything work as I wanted it to:
ArrayFormula({SPLIT(TRANSPOSE(Base_Data!A2)&"|"&TRANSPOSE(Base_Data!AJ1:1&"|"&Base_Data!AJ2:2),"|")})
What I want:
I'd like to extend the formula to work for the entire area, all 53 rows. Does anyone have a tip for this? The solution doesn't have to be a formula, it would work as a script, too
I've set up a new sheet called "New_Data [Erik]" and placed the following formula into A2:
=ArrayFormula(SPLIT(FLATTEN(Base_Data!A2:A&"\"&Base_Data!AJ1:1&"\"&Base_Data!AJ2:54),"\",0,1))
If this is a one-time conversion, I'd recommend copying the results in place. To do that, select A:C, hit Ctrl-C to Copy and then Ctrl-Alt-V to Paste Special. A small clipboard icon will appear. Click it and choose "Paste Values Only."
If you'll need this functionality ongoing, just understand that FLATTEN is a not-yet-official function of Google Sheets, which means that while Google sheets may very well make it official, they may also decide to do away with it at any time. (This is why I suggest copying and pasting the results in place, if it's just a one-time conversion.)
Not sure what you're trying to get to there. If you are trying to leave out all columns but 3, just do ={Base_Data!A2:A, Base_Data!E2:E} and add as many columns as you require comma-separated within the curly brackets

How to send cell data from one google spreadsheet to another, but only if the cell colour is correct?

I have a spreadsheet with cells coloured in two different colours. I know I can send all the cell data from one google spreadsheet to another using IMPORTRANGE function. However, I only want to send the cell data if it satisfies a specified cell colour.
For example, if spreadsheet A has 10x10 data with various colours, then spreadsheet B should contain all the data from cells in spreadsheet A that are either red or green (and also transfer the cell colours). All other cells with different colours from spreadsheet A should be transferred to spreadsheet B as blank colourless cells. The resulting spreadsheet should still contain 10x10 cell data, but with only red, green and blank cells.
I know it should be possible to write a function for this, but I have never written any custom functions before and have no Javascript experience. Any kind of help would be appreciated. Perhaps also the QUERY function could be of use?
Thanks in advance!
You should check about Google Apps Script. It gives you a set of tools that will allow you to create a script for doing what you want.
Custom Functions will help you to create a function that lets you get the values from your sheet and then set the conditions you are requiring.
The Class SpreadsheetApp has the tools for handling all data in your sheets. Check for example the method getBackgrounds(), which gets the color in a range of cells.
This another post, it is a little similar in some aspects to what you want to do.
It's best practice to create an additional column which stores the information regarding as to which condition (color) is applied 5o the particular row. Once you have done that, you can easily transport a table from one Spreadsheet to another using the QUERY formula within the IMPORTRANGE.
Image column a is the name of a city.
Imagine column b holds the information regarding the condition (color). This is an helper column.
Now we have col1 = New York City, col2= green
Then you could enter this into the new sheet.
QUERY( IMPORTRANGE(URL, range), "SELECT col1 WHERE col2="green" OR col2="yellow" OR col2="red")
Here is a great tutorial series I like to use.
https://youtu.be/_N5zhAipVn0

Is there an easy workaround for an "Evaluate" function in Google Spreadsheets?

I have created text templates with a few placeholders for keywords. The keywords are in separated cells and there are a lot of them. The idea is, that I select a text template with a dropdown menue on a different sheet and it fills the selected text with all the keywords automatically. I get my template via VLOOKUP and using SUBSTITUTE and ROW to replace the row numbers to get the right keywords from the same row. So far so good.
What I dont't get is the final evaluation. The output is always a formula that is just a text and not a functional formula.
I know that there is no EVAL function for Google spreadsheets like in Excel. So I need a workaround.
Tried so many things, like INDIRECT functions or some scripts from the internet for a self made EVAL function, but still couldn't get a working thing. I'm going crazy.
//MY TEMPLATES:
A B
Version No.1 ""&CXXXXX&" & "&DXXXXX&" presents for your "&EXXXXX&"."
Version No.2 "Perfect for "&CXXXXX&" & "&DXXXXX&". Do some "&EXXXXX&"!"
Version No.3 "Cool "&CXXXXX&" & "&DXXXXX&"."
//MY KEYWORDS:
C D E
Business Money Motivation
Fitness Bodybuilding Sports
Music Songs Sounds
//MY CODE FOR THE EXPECTED OUTPUT:
=CONCATENATE("=";SUBSTITUTE(VLOOKUP($A3;$A$16:$B$18;2;0);"XXXXX";ROW(B3)))
(Templates are placed at A16:B18)
//WHAT I ACTUALLY GET:
Dropdown Output
Version No.2 ="Perfect for "&C3&" & "&D3&". Do some "&E3&"!"
Version No.3 ="Cool "&C4&" & "&D4&"."
Version No.1 =""&C5&" & "&D5&" presents for your "&E5&"."
//WHAT I NEED:
Dropdown Output
Version No.2 Perfect for Business & Money. Do some Motivation!
Version No.3 Cool Fitness & Bodybuilding.
Version No.1 Music & Songs presents for your Sounds.
The output has to be evaluated but I didn't figured out how I can do that in Google Spreadsheets...
Here you can find the example file:
https://docs.google.com/spreadsheets/d/11vvkhgsbPqDz5sPCkPzNcGNvlHEBhRE72O8pE_keDs0/edit?usp=sharing
Use Google Apps Script or the Google Sheets API to add your formula to a cell.
If you go for using Google Apps Script, use setFormula or setFormulaR1C1 to add a single formula.
Perhaps you should start by reading https://developers.google.com/apps-script/guides/sheets

Google spreadsheets auto fill formula with form submission

I am trying to get my Google form submissions set up so I can produce a PDF with Auto Crat with the right information since my form has yes and no questions.
I need 4 different columns to auto fill with my different but similar formula below as my first sheet is filled using IMPORTRANGE from my Form submissions master sheet. If there is an easier way to do all this please let me know since I am really new to Google formulas.
=if(Sheet1!P3="Yes", (CONCATENATE("My yes answer "&CHAR(10)&CHAR(10)&"<b>Employee name:</b> "&Sheet1!Q3&CHAR(10)&"<b>Location (room number where the employee will be during the emergency):</b> "&Sheet1!R3&CHAR(10)&"<b>Telephone number (room where the employee will be during the emergency):</b> "&Sheet1!S3&CHAR(10)&"<b>Critical operation:</b> "&Sheet1!T3)), "it is the no response")
Here is the Master
Here is the two sheets I am using. The first pulls in the information and the second sheet is where I use my formulas.
I was able to get an add-on to sheets called copyDown to copy the formula down the rows for me. This helped me to keep it all on one sheet instead of having two sheets so I could use AutoCrat for compiling my PDF correctly. Thank you for all the help in solving this issue.

Questions about data formatting using UiApp and google spreadsheet

Thank you in advance for any help you can provide. As background, I built a simple UiApp using GAS that I use to populate a google spreadsheet and a calendar with entries about events including time, date, location, etc. I've had it working for awhile but I want to keep improving it and I have a few questions about format and functionality.
1.) I now want the script to copy the information to a second spreadsheet, I've established how to do this, but the second spreadsheet already has some columns in use that I don't want to override and I don't want to just place the info from this Ui into the first 'X' number of columns, is there any easy way to essentially "copy these 5 columns to the first then skip and column and bring in the rest". Here is the code I have for the copy action right now:
var ss = SpreadsheetApp.openById(ssID);
var sheet = ss.getSheets()[0];
sheet.getRange(sheet.getLastRow()+1, 1, 1, 20).setValues([[new Date(), eventTitle, eventDateFrom, eventStartTimeb, eventEndTimeb, eventLocationName, eventLocationCity,eventActivity, eventLeadContact, eventNSLContact, eventContactAttending, eventDepartment, eventStaff, eventMaterials, eventCost, eventIncentive, eventMSTarget, eventSolar, eventNotes,eventRegion]]);
Also, in the same vein as this question, I've been wondering if it is possible to write something that will choose when an entry is copied to the second spreadsheet based on the value of one of the elements. For example, if eventStaff=0 or is blank, the script will copy the designated information to first spreadsheet but not the second.
2.) Date format: I added two listboxes for to capture event time start and event time end and I would like them to show up in the spreadsheet formatted as 00:00 AM/PM, but have only accomplished to get 00:00:00 or whole number so far.
3.) Using multiple elements to fill the location and events portion of calendar entries. This script works to create a basic event with start/end time and a title, but I'd like to use some of the information to fill in the location and description of an event. Is there a way for me to do this or do I need to concatenate those fields into one in able to enter them in the event creation. Current event creation code:
cal.createEvent(eventTitle,eventDateFrom,eventDateTo);
Sorry for the wall of text, if any clarification/additional code sample is needed just ask. Thank you in advance for any help/insight you might be able to provide.
Please don't be offended but I'm afraid your questions are more general programming question than GAS question, by formulating the question you almost answer it by yourself (question 1).
As for question 2, have a look to Utilities.formatDate and you'll get what you want, see also this.
Question 3: see CalendarApp documentation, createEvent, there is a set of optional arguments that suits your needs. - best regards,