TASK_FORMULA is a powerful custom function in the Sheet Workflows addon that enables you to generate Google Sheets formulas using AI language models. It allows you to describe what you need in plain English, and the AI will create an appropriate formula for your spreadsheet, placing it directly in a specified cell.
TASK_FORMULA(range, cell_address, prompt, [model], [additional_sheets])
Parameter | Data Type | Required | Description |
---|---|---|---|
range |
|
Required | The range in the active sheet to use as context for the formula. Example:
|
cell_address |
|
Required | The cell address where the generated formula will be placed. Example:
|
prompt |
|
Required | Instructions describing the formula to generate. Example:
|
model |
|
Optional | The name of the language model to use (format: 'provider/model_name'). Example:
|
additional_sheets |
|
Optional | Additional sheets and their ranges to include as INPUT only, separated by semicolons. Example:
|
You can specify which AI model to use for formula generation by passing the model parameter:
=TASK_FORMULA("A1:D10", "E1", "Create a VLOOKUP formula to find matching data", "Gemini/gemini-1.5-pro")
Available models depend on which providers you've configured in the Sheet Workflows addon. Some examples include:
"Gemini/gemini-1.5-pro"
"OpenAI/gpt-4"
"Anthropic/claude-3-opus"
When your formula needs to reference data from multiple sheets, use the
additional_sheets
=TASK_FORMULA("Orders!A1:D20", "Summary!B5", "Create a formula that counts unique customers", , "Customers(A1:B50);Products")
This provides the formula generator with context from:
If you need your formula to work when copied to other rows:
"Create a formula that multiplies the price in column B by the quantity in column C, ensuring it works when copied down"
When specifying the cell_address parameter, you can provide just a column letter, and the function will use the current row:
=TASK_FORMULA("A1:C10", "D", "Create a formula to total columns A through C")
This is useful when creating formulas that need to be copied down an entire column.
=TASK_FORMULA("A1:B10", "C1", "Create a formula that adds the values in column A and multiplies the result by the value in B1")
This will generate a formula like
=SUM(A1:A10)*B1
=TASK_FORMULA("A1:B10", "C1", "Create a formula that calculates the number of days between dates in columns A and B")
The function might generate
=B1-A1
=TASK_FORMULA("A1:D10", "E1", "Create a formula that shows 'Complete' if column D has a date, otherwise 'Pending'")
This would generate a formula like
=IF(ISBLANK(D1),"Pending","Complete")
=TASK_FORMULA("Inventory!A1:C20", "Dashboard!B5", "Create a formula to count items with less than 10 units in stock", , "Orders(A1:E50)")
This could generate
=COUNTIFS(Inventory!C1:C20,"<10")
=TASK_FORMULA("A1:C10", "D1", "Create a formula that extracts the first name from the full name in column A")
Might generate
=LEFT(A1,FIND(" ",A1)-1)
Be Specific: Provide clear, detailed instructions in your prompt. The more specific you are, the better the formula will be.
Reference Key Columns: Mention which columns contain the data you need to process in your prompt.
Include Business Logic: Explain any rules or conditions that the formula should follow.
Provide Adequate Context: Make sure your range parameter includes all the data the formula needs to reference.
Use Appropriate Cell References: Indicate whether absolute or relative references are needed if you plan to copy the formula.
Check Results: Always verify that the generated formula produces the expected results.
Start Simple: For complex problems, start with a simple formula and then build on it.
Use Multiple Sheets Judiciously: Only include additional sheets if they're relevant to the formula.
Problem: The function returns an error instead of generating a formula.
Solution:
Problem: The formula is created but doesn't produce the expected results.
Solution:
Problem: The function returns a #NAME? error.
Solution: Make sure the Sheet Workflows addon is properly installed and activated.
Problem: The function can't write the formula to the specified cell.
Solution: Ensure you have edit permissions for the spreadsheet.
Problem: You get an error about an invalid range.
Solution: Make sure all range references are in valid A1 notation format and within the sheet's dimensions.
Yes, use the
additional_sheets
Yes, like any Google Sheets formula, the generated formula will recalculate whenever the referenced data changes.
No, each TASK_FORMULA call generates a formula for a single cell. To create formulas for multiple cells, you'll need to:
Be explicit in your prompt that you need the formula to work when copied down, and the AI will generally use relative references where appropriate.
The function itself is part of the Sheet Workflows addon, but it uses AI models that may have associated costs depending on your configuration. Check the pricing for the specific AI provider you're using.
Yes, once the formula is placed in the cell, you can edit it like any other formula in Google Sheets.
You'll need to configure at least one AI provider in the Sheet Workflows addon settings before using this function. The addon supports various providers including Google Gemini, OpenAI, Anthropic, Groq, and others.
Yes, you can request any type of Google Sheets formula. Just be specific in your prompt about needing an ArrayFormula or other advanced formula types.
5 months ago
1 month ago
1 month ago