Skip to main content

Spreadsheet AI Functions

General Functions​

SAI.ASK​

Makes up a prompt, submits it to the AI, and outputs the result in a single value or an array. This is the most general, powerful, and versatile AI function to use.

Signature​

=SAI.ASK([prompt_part1], [prompt_part2], ...)

  • 'prompt_part1', 'prompt_part2',... can be a value, a cell, a range, etc.
  • You can enforce the form (e.g., a single value, a vertical list, a table) of the output in the prompt, or you can leave the AI to decide.

Examples​

  • =SAI.ASK("give me a random number")
  • =SAI.ASK("give me the 5 biggest cities of the US in a vertical list")
  • =SAI.ASK(A1:B1) where A1 is "what is the biggest city of" and B1 is "United States".
  • =SAI.ASK("find the 3 largest values from", A1:A10, "and join them with a comma") where A1:A10 are numbers. The formula returns the result in a single cell.
  • =SAI.ASK("find the common values of", A1:A5, "and", B1:B5, "then remove any duplicates and return a horizontal list") The formula returns the result in a horizontal list.
  • =SAI.ASK("join the tables", A1:B5, "and", C1:D10) The formula joins the contents of the two tables, returning a larger table.
  • =SAI.ASK("retain only the people listed in", A1:A10, "within the table", B1:D30") where A1:A10 is a list of people and B1:D30 is a table of people and other contents. The formula returns a table, keeping only the rows where the people match those listed in A1:A10.

SAI.PROMPTARRAY​

Submits an array of prompts to the AI and returns an array of corresponding responses, preserving the same dimensions.

Signature​

=SAI.PROMPTARRAY(prompts)

  • 'prompts' is an array of prompts (e.g., a range of prompt texts).
  • The function returns an array of corresponding responses that has the same dimensions as the 'prompts' parameter.

Examples​

  • =SAI.PROMPTARRAY(A1:A10) where A1:A10 are different prompts. The formula returns the list of corresponding responses.
  • =SAI.PROMPTARRAY("what's the capital of " & B1:B3) where B1:B3 are "US", "France", and "Italy". The formula returns the list of "New York City", "Paris", and "Rome".

Table Generation and Completion​

SAI.GENERATETABLE​

Submits a prompt to the AI and outputs the results in a table.

Signature​

=SAI.GENERATETABLE(prompt, [head], [inputs])

  • 'prompt' is the instruction to generate a table.
  • 'head' contains at least one row. The first row is headers; the following rows can be used to specify examples.
  • 'inputs' contains partial rows to complete.

Examples​

  • =SAI.GENERATETABLE("generate 5 sample people from different cities in the US who work in the marketing industry")
  • =SAI.GENERATETABLE("generate 5 sample people from the US", A1:A6) where A1:A5 are "Name", "City", "Job title", "Industry", and "Company".
  • =SAI.GENERATETABLE("Add top color, calories and weight to this list of fruit", A1:D1, A2:A5) where A1:A4 are "Fruit", "Color", "Calories", and "Weight"; A2:A6 are "Apple", "Orange", "Banana", and "Coconut".

SAI.FILL​

Completes a table by learning examples. The function for the Flash Fill feature of Excel.

Signature​

=SAI.FILL(examples, [inputs])

  • 'examples' contains the data that the AI should learn the patterns from.
  • 'inputs' contains the data that the AI should complete.

Examples​

  • =SAI.FILL(A1:B1, "Satya Nadella") where A1:B1 are "Bill Gates" and "Gates". The formula returns "Nadella".
  • =SAI.FILL(A1:B1, "128-345-214") where A1:B1 are "123-456-789" and "(123) 456 789". The formula returns "(128) 345 214".

Data Manipulations​

SAI.SPLIT​

Splits a text semantically, such as into sections, paragraphs, sentences, words, or based on punctuation.

Signature​

=SAI.SPLIT(text, split_by)

  • 'text' can be a single value. It can also be an array, in which case the function will combine the texts of that array.
  • 'split_by' can be, for instance, "sections", "paragraphs", "sentences", or "punctuation".
  • The function returns a vertical list.

Examples​

  • =SAI.SPLIT("This is really nice", "word") The formula returns a vertical list of "This", "is", "really", and "nice".
  • =SAI.SPLIT(A1:A2, "word") where A1:B1 are "This is" and "really nice". The formula returns a vertical list of "This", "is", "really", and "nice".

SAI.EXTRACT​

Extracts data (like email addresses or company names) from a text.

Signature​

=SAI.EXTRACT(text, to_extract)

  • 'text' can be a single value. It can also be an array, in which case the function will combine the texts of that array.
  • 'to_extract' can be a single value. It can also be an array, in which case the function processes each value within the array sequentially and returns an array of the resulting extractions, maintaining the same dimensions as the 'to_extract' parameter.
  • The function returns a single value when 'to_extract' is a single value (in cases where multiple extractions occur, they are merged into one string, separated by commas). When 'to_extract' is an array, the function returns an array of the same dimensions.

Examples​

  • =SAI.EXTRACT("China Italy France are 3 countries", "country") The formula returns a value "China, Italy, France".
  • =SAI.EXTRACT(A1:A2, "country") where A1:A2 are "Here is France" and "There is Italy". The formula returns a value "France, Italy".
  • =SAI.EXTRACT("jone.smith@example.com 555-123-456", A1:A2) where A1:A2 are "email" and "phone number". The formula returns a vertical list of "jone.smith@example.com" and "555-123-456".

SAI.EXTRACTARRAY​

The array function of SAI.EXTRACT. It processes extraction on an array of texts and returns an array of corresponding extractions, preserving the dimensions.

Signature​

=SAI.EXTRACTARRAY(texts, to_extract)

  • 'texts' is an array of texts.
  • 'to_extract' should be a single value.
  • The function returns an array, extracted from the 'texts' parameter, that has the same dimensions as the 'texts' parameter.

Examples​

  • =SAI.EXTRACTARRAY(A1:A2, "country") where A1:A2 are "Here is France" and "There is Italy". The formula returns the list of "France" and "Italy".

SAI.EDIT​

Applies a task to a value, e.g., fixing the grammar and spelling of a text.

Signature​

=SAI.EDIT(value, task)

  • 'value' can be a single value. It can also be an array, in which case the function will combine the values of that array.
  • 'task' should be a single value.
  • The function returns a single value that is the result of applying the 'task' to the 'value'.

Examples​

  • =SAI.EDIT("My englsh is nt good.", "fix grammar and spelling") The formula returns "My English is not good.".
  • =SAI.EDIT(A1:B1, "fix grammar and spelling") where A1:B1 are "My englsh" and "is nt good". The formula returns "My English is not good.".

SAI.EDITARRAY​

The array function of SAI.EDIT. It applies a task to an array of values and returns an array of corresponding results, preserving the dimensions.

Signature​

=SAI.EDITARRAY(values, task)

  • 'values' is an array of values.
  • 'task' should be a single value. The function returns an array that has the same dimensions as the 'values' parameter.

Examples​

  • =SAI.EDITARRAY(A1:B1, "fix grammar and spelling") where A1:B1 are "My englsh" and "is nt good". The formula returns the list of "My English" and "is not good".

SAI.FORMAT​

Formats texts, dates, currencies, addresses, names, etc.

Signature​

=SAI.FORMAT(value, target_format)

  • 'value' can be a single value. It can also be an array, in which case the function will combine the values of that array.
  • 'target_format' should be a single value, e.g., "iso", "title case", "uppercase".
  • The function returns a single value that is the result of applying the 'target_format' to the 'value'.

Examples​

  • =SAI.FORMAT("2023 feb 24", "iso") The formula returns the date 2023-02-24.
  • =SAI.FORMAT("This is a title", "title case") The formula returns "This Is An Title".

SAI.FORMATARRAY​

The array function of SAI.FORMAT. It applies a format to an array of values and returns an array of corresponding results, preserving the dimensions.

Signature​

=SAI.FORMATARRAY(values, task)

  • 'values' is an array of values.
  • 'target_format' should be a single value, e.g., "iso", "title case", "uppercase".
  • The function returns an array that has the same dimensions as the 'values' parameter.

Examples​

  • =SAI.FORMAT(A1:A2, "iso") where A1:A2 are "2023 feb 24" and "2023 feb 25". The formula returns the list of the date 2023-02-24 and the date 2023-02-25.

Content Analyses​

SAI.CLASSIFY​

Classifies a text into a category.

Signature​

=SAI.CLASSIFY(text, categories)

  • 'text' can be a single value. It can also be an array, in which case the function will combine the texts of that array.
  • 'categories' can be a single string value of comma-separated category names. It can also be an array of category names.
  • The function returns the most relevant category that the 'text' belongs to.

Examples​

  • =SAI.CLASSIFY("banana", "fruit, vegetable") The formula returns "fruit".
  • =SAI.CLASSIFY("banana", A1:A2) where A1:A2 are "fruit, vegetable" and "meat". The formula returns "fruit".

SAI.CLASSIFYARRAY​

The array function of SAI.CLASSIFY. It classifies an array of texts and returns an array of corresponding categories, preserving the dimensions.

Signature​

=SAI.CLASSIFYARRAY(texts, categories)

  • 'texts' is an array of texts.
  • 'categories' can be a single string value of comma-separated category names. It can also be an array of category names. The function returns an array of categories that has the same dimensions as the 'texts' parameter.

Examples​

  • =SAI.CLASSIFYARRAY(A1:A2, "fruit, vegetable") where A1:A2 are "banana" and "potato". The formula returns the list of "fruit" and "vegetable".

SAI.TAG​

Applies user-defined tags to a text.

Signature​

=SAI.TAG(text, tags)

  • 'text' can be a single value. It can also be an array, in which case the function will combine the texts of that array.
  • 'tags' can be a single string value of comma-separated tag names. It can also be an array of tag names.
  • The function returns a single string containing the tags (separated by commas if multiple) relevant to the 'text'.

Examples​

  • =SAI.TAG("I love banana", "fruit, positive, negative") The formula returns the value "fruit, positive".
  • =SAI.TAG("I love banana", A1:A3) where A1:A3 are "fruit", "positive", and "negative". The formula returns the value "fruit, positive".

SAI.TAGARRAY​

The array function of SAI.TAGARRAY. It tags an array of texts and returns an array of corresponding tags, preserving the dimensions.

Signature​

=SAI.TAGARRAY(texts, tags)

  • 'texts' is an array of texts.
  • 'tags' can be a single string value of comma-separated tag names. It can also be an array of tag names.
  • The function returns an array that has the same dimensions as the 'texts' parameter. Each element of the resulting array is a single tag or a string of comma-separated tags.

Examples​

  • =SAI.TAGARRAY(A1:A2, "positive, negative") where A1:A2 are "I love banana" and "I don't like potato". The formula returns the list of "positive" and "negative".
  • =SAI.TAGARRAY(A1:A2, "fruit, positive, negative") where A1:A2 are "I love banana" and "I don't like potato". The formula returns the list of "fruit, positive" and "negative".

SAI.SUMMARIZE​

Summarizes a text according to a format.

Signature​

=SAI.SUMMARIZE(text, format)

  • 'text' can be a single value. It can also be an array, in which case the function will combine the texts of that array.
  • 'format' should be a single value, e.g., "less than 20 words", "3 sentences".
  • The function returns a string value.

Examples​

  • =SAI.SUMMARIZE(A1, "3 sentences") where A1 is a long text. The formula returns a summary.
  • =SAI.SUMMARIZE(A1:B5, "less than 50 words") where A1:B5 is a range of texts. The formula returns a summary.

SAI.SUMMARIZEARRAY​

The array function of SAI.SUMMARIZE. It summarizes an array of texts and returns an array of summaries, preserving the dimensions.

Signature​

=SAI.SUMMARIZEARRAY(texts, format)

  • 'texts' is an array of texts.
  • 'format' should be a single value, e.g., "less than 20 words", "3 sentences".
  • The function returns an array that has the same dimensions as the 'texts' parameter.

Examples​

  • =SAI.SUMMARIZEARRAY(A1:A10, "3 sentences") where A1:A10 are 10 long texts. The formula returns the list of 10 summaries.

Availability​

Currently, the spreadsheet AI functions are only available in Excel add-in and not in Google Sheets add-on.