Questions tagged [custom-function]

DO NOT USE THIS TAG ALONE. Unlike built in functions where the functions are designed by the product designers for mass use, Custom functions are functions that are custom designed for only a subset of end users. Use for questions relating to such functions along with the product in question(eg [sql], [google-sheets],[excel]).

545 questions
212
votes
10 answers

Syntax behind sorted(key=lambda: ...)

I don't quite understand the syntax behind the sorted() argument: key=lambda variable: variable[0] Isn't lambda arbitrary? Why is variable stated twice in what looks like a dict?
Christopher Markieta
  • 5,674
  • 10
  • 43
  • 60
124
votes
22 answers

Refresh data retrieved by a custom function in Google Sheet

I've written a custom Google Apps Script that will receive an id and fetch information from a web service (a price). I use this script in a spreadsheet, and it works just fine. My problem is that these prices change, and my spreadsheet doesn't get…
tbkn23
  • 5,205
  • 8
  • 26
  • 46
113
votes
24 answers

Selecting the last value of a column

I have a spreadsheet with some values in column G. Some cells are empty in between, and I need to get the last value from that column into another cell. Something like: =LAST(G2:G9999) except that LAST isn't a function.
46
votes
6 answers

RMSE/ RMSLE loss function in Keras

I try to participate in my first Kaggle competition where RMSLE is given as the required loss function. For I have found nothing how to implement this loss function I tried to settle for RMSE. I know this was part of Keras in the past, is there any…
dennis
  • 707
  • 1
  • 8
  • 12
33
votes
4 answers

Custom function throws a "You do not have the permission required to setValue" error

I am trying to set some value to a cell in a Google Spreadsheet: function exampleFunction() { var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; var range1 = sheet.getRange("A1"); var value1 =…
32
votes
4 answers

Import JSON data into Google Sheets

I am pulling data from a web service and it is formatted as JSON. I am writing a Google Apps Script for Google Sheets that will populate the data for me. My problem is, I can't seem to get it to parse out. Doing: var dataset =…
26
votes
2 answers

In Apps Script, How to include optional arguments in custom functions

I want to write a custom function which has some mandatory arguments but can also accept a few optional arguments. I couldn't find any documentation on this. Does anyone know? Is it similar to Javascript?
23
votes
13 answers

ALL Custom Functions return "unknown function" in one spreadsheet, but work in others

I have a few Simple Custom Functions that I use all the time. I have recently run into a spreadsheet that I desperately need to use them in, but when I try to use even the most basic custom functions, I get "#NAME?" with a hover text of "unknown…
Bob Wold
  • 371
  • 1
  • 3
  • 5
22
votes
4 answers

Function to sort an array and return the sorted array

PHP's native sorting functions modify by reference and do not return the sorted array. I am looking for a reliable standard method to sort an array, returning the sorted array as the return value. All of the PHP.net functions I have read about…
István Pálinkás
  • 2,217
  • 7
  • 25
  • 50
19
votes
3 answers

Passing cell references to spreadsheet functions

When I call a spreadsheet function, say int(f2), the function operates on the value in the cell. If cell("F2") contains 3.14159, the result would be 3. But when I call a different type of function — for example: row(f8) — the function takes the cell…
HardScale
  • 971
  • 1
  • 7
  • 18
18
votes
0 answers

Script to summarise data not updating

I have a Google spreadsheet of timesheet data; it has a sheet for each month, each sheet is a lot of six column blocks, one block per client. I have created a summary sheet that goes and gets the total for each clients and displays it in a…
18
votes
4 answers

Passing arguments / parameters from a Google sheets custom function to the script function

I'm stuck on a something basic. How do I pass arguments to a Google Sheets custom function. I have a function in the Apps Script code editor defined as: function usageByMonth(range,theDate) { // do something with the arguments passed } In my…
14
votes
2 answers

Service Invoked Too Many Times (Google Apps Script)

I want to use Google Apps Script to make custom functions for a spreadsheet. I've made an extremely simple function: function foo(){ return "bar"; }; The problem is that I need this function in a couple hundred cells. When I paste the function…
jrc03c
  • 301
  • 1
  • 2
  • 6
13
votes
1 answer

Using Built-in function inside Custom Function

In google sheets, I'd like my custom function to use one of the built-in functions. Specifically, this function would take a string as a parameter, comb through another sheet to locate that value, and then return a link to that cell's…
ZAR
  • 2,550
  • 4
  • 36
  • 66
12
votes
1 answer

How do I get the value from an adjacent cell using Google Script in a Google Spreadsheet?

I apologise if this has been asked before but I've looked for an example and unfortunately I'm unable to find an answer hence why I'm asking here. If I have a custom function in a Google Spreadsheet how do I get the value of a cell if the contents…
user1408643
  • 731
  • 2
  • 7
  • 14
1
2 3
36 37