# Spreadsheet AI Functions

### Use AI functions to build formulas and spreadsheets with natural language

## Introductionâ

We have published 17 Spreadsheet AI functions within Spreadsheet AI for Excel. These functions can be directly used in Excel formulas. They construct prompts from spreadsheet cells and ranges, send them to AI models, and seamlessly retrieve the results.

#### The all-powerful AI function - SAI.ASK:â

With SAI.ASK, you no longer need Excel's built-in functions, pivot tables, or laborious manual work. Whether you're looking to generate, merge, or manipulate lists and tables, simply articulate your requirements in natural language, and SAI.ASK does it with one simple command.

#### Specialized AI functions to classify, extract, format, genearte, etc.:â

We also provide specialized AI functions to cater to various specific operational needs. For instance, for data manipulation, SAI.EXTRACT, SAI.EDIT, and SAI.FORMAT allow users to respectively extract, edit, and format data; SAI.CLASSIFY, SAI.TAG, and SAI.SUMMARIZE enable users to classify, tag, and summarize content.

#### Apply AI functions to a large volume of rows:â

You can apply a prompt to many cells by simply copy-pasting or dragging a formula. We also provide AI "array" functions, such as SAI.EDITARRAY and SAI.FORMATARRAY. These AI array functions work similarly to Excel's built-in array functions, allowing you to apply them to an entire list or table and return an array. For spreadsheets with extensive arrays, leveraging these array functions is indispensable for maintaining a streamlined and effective calculation chain.

## Availabilityâ

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

## 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.

#### Videoâ

### 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)

- '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)

- '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.