Excel(Google Sheets) ArrayFormula + If statment with one output? - google-sheets-query

I have the following formula:
=ARRAYFORMULA((IF(B16>C16:F16, "Some Text", "")))
What I am trying to achieve is:
If B16 is greater than each of C16:F16 then the cell text should be "Some Text".
Currently the formula will poulate a cell with "Some Text" for each C16:F16 rather than just once. Is there any way to achieve this?

Nothing to do with Google's Visualization API Query Language, but perhaps achieves the result you wanted:
=if(B16>min(C16:F16),"some text","")

Related

using formulas and hyperlink in the same cell

So the main idea is I want to put a Hyperlink on a cell that contains a formula, But google sheet don't like that.
I had 2 ideas.
1- Put the formula in cell A1 and the output of that formula is dumped into cell A2 which is gonna be Hyperlinked.
(I tried to use FILTER to pull data into the Hyperlinked cell but it would give me a #REF! error:Array result was not expanded because it would overwrite data in A2.)
2- Use some sort of apps-script of which I have very little understanding of, so I didn't find any scripts relating to my question.
I didn't understand the reason why you can't put a Hyperlink AND a formula in the same cell, But as far as I understood:
Hyperlink is a formula it self → =HYPERLINK(url, [link_label])
So instead of Hyperlinking our cell using the UI, we can use the formula form to Hyperlink the cell and use our formula in the place of [link_label] which is gonna be the name of our cell:
=HYPERLINK( url , [link_label])
=HYPERLINK("google.com", SUM(B2:B5 ))

Do I need a script or a formula?

I am trying to have the formula look in Column A for not empty cells. (That part of the formula works fine.) Then return the name from Column B that's in the same row as the not empty cell.
Column A Column B
text/date Kelly
So if B has anything in it, tell me the name Kelly. I 've tried combining formulas, but I'm either not doing it correctly or maybe I need a script?
Here's the part that's working: =IF(A24="","don't meet","meet")
Of course, I want it to search the whole column, but I know for sure 24 has the text in the cell with a name so I was just playing around that line.
Answer is based on the description and document you provided and should give you something to work with.
This formula simple checks the entire Column A and returns values from the corresponding row from Col B if the Cell from the Col A row is empty/blank.
=ARRAYFORMULA((IF(A1:A<>"",B1:B,"")))
Here are example screenshots of your example data + end result
Though I'm not entirely sure what you'd like to happen if A has values on them. This formula retains A if it has content but you could always change the (A2:A="",B2:B,A2:A) part of the formula if you want something else to happen if A is not empty.
Give this a try, I put it in your sheet in the green area.
=ARRAYFORMULA(IF(A1:A15 = "", "", B1:B15))
Arrayformula applies the IF function to the entire range. So substitute A1:A15 with what ever the whole range is, A1:A600 or A1:A if you want to do the whole column. Make srue the second column has the same values but with B.
You can use filter() to filter your Column B if both column A and column B is not empty.
Formula:
=filter(B1:B,A1:A<>"",B1:B<>"")
Output:

Google sheets query with text

This is probably a very stupid question but I can't seem to find an answer for it anywhere. I'm trying to use a simple COUNTA query but I also want text to appear so something like this
"Amount = "=COUNTA(B16:B25)
=(your text) & (your formula output)
="Amount: " & COUNTA(A:A)
should work.

Bold conditional formatting script for Google Spreadsheets

What I want to do is essentially what this user wanted to do here:
I need a script that formats the cells in column A bold, but only the cells that contain the word 'Hello'.
However I have no knowledge of Google Apps scripts at all, and I need an answer put in much simpler terms than what I could find there or anywhere else. Any help is appreciated; thank you!
To start, from your spreadsheet, open "Tools / Script Editor...". When the dialog opens, choose to "Create Script For... Spreadsheet". You will end up with a sample script - we're going to edit it to do what you want.
Change the readRows() function as shown here. The change is that instead of logging the content of every row, we will use an if statement to check if the cell contains a string with 'Hello' in it. Then, if it does, we'll bold the cell text.
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
var values = rows.getValues();
// Arrays start at 0, Google Sheets start at 1 - must remember that.
// We will loop starting at 1, because we want to skip the header in
// Row 1, aka Array index 0
for (var i = 1; i <= numRows - 1; i++) {
var colA = values[i][0];
if (colA.toString().indexOf('Hello') >= 0) {
sheet.getRange(i+1,1).setFontWeight("bold");
}
}
};
Now, how to run that? The sample already has an onOpen() function that will set up a custom menu... let's just change the text it displays in the User Interface, as shown here. The only change is in the 'name' property of the menu entries.
function onOpen() {
var sheet = SpreadsheetApp.getActiveSpreadsheet();
var entries = [{
name : "Bold Hello",
functionName : "readRows"
}];
sheet.addMenu("Script Center Menu", entries);
};
Save your script. Go back to your spreadsheet, and reload it (to get it to run the onOpen trigger function). When your menu shows up, you're all set.
Next - start with the "First Script" tutorial here. The Google Apps Script documentation covers all the services provided by Apps Script, but the basic language structure and objects are javascript, so you should get familiar with that. Just try googling "learn javascript", and you'll find tons of tutorials, books, and other resources.
I can't make this simpler.
In the now not so new 'New' Sheets this can be achieved without a script:
Clear formatting, select ColumnA and Format, Conditional formatting..., Format cells if... Text contains and:
hello
Then for Formatting style click the B and Done.
This way is not case sensitive and will embolden contents such as OTHELLO.
If you aren't trying to set too many conditional formatting rules, there's an easier way to set colors, though not bold. In Google Drive Spreadsheet, click the "Format" menu. The bottom menu item should be "Conditional formatting..."; click that. That should produce a dialog box that defaults to something like this (to the extent that I can draw it with text):
x
Conditional formatting
[Text contains ◊ ] [ ] []Text: [ ] []Background: [ ] x
e.g. "done" or "Jonathan"
_______________________________________________________________________________
+ Add another rule
[ Save rules ] [ Cancel ]
In your example, you're looking for cells that contain "Hello", so the default of "Text contains" would do the job. Put "Hello" into the text box, and set a format in the "Text":" and "Background:" boxes. That doesn't give you bold, but it does allow colors.
I see that your question dates back half a year, so it's probably too late for you (and if you strictly need bold, it doesn't solve the problem anyway), but it may help others.

google spreadsheet importxml, chop off part of query

I have a simple ImportXml function in Google spreadsheet:
=ImportXml( "http://www.google.com/finance?q=0322.hk", "//span[#class='chr']" )
but it is giving me 2 cells of data, the cell direction underneath it is a =Continue(blah blah)... automatically placed by Google.
Here is the HTML code associated with this page. Looks like it has 2 items. I've replaced "<" & ">" with "(" & ")"
(span class="ch bld")(span class="chr" id="ref_673324_c")-0.45(/span)
(span class="chr" id="ref_673324_cp")(-2.02%)(/span)
How do I change my ImportXml function so that I'm only importing the "-0.45" without the "(-2.02%)?
I've also found that the INDEX command works... useful too if you want the 2nd (-2.02%) item in the results. One important note, though, is that you've got to first transpose the output of ImportXML or it won't work.
=INDEX( TRANSPOSE (ImportXML (...)), {num}) where num is the desired result.
I found a work around... I put =NOEXPAND function infront of it and it works. but if anybody has another solution let me know.