Download Reportworq
⬇ Guide PDF

The AI insight function#

RW.Tools.AIInsight calls a configured AI provider with a prompt and writes the response directly into a named Excel TextBox or a target cell at report-generation time. Use it to embed AI-generated summaries, commentary or analysis into a report without any manual copy-and-paste step.

Alias: RWAIINSIGHT.

This is the only generative worksheet function. The AI*-aliased functions (AIEXTRACT, AIINPUT and the rest) are the Workday Adaptive connector, where "AI" stands for Adaptive Insights. They have nothing to do with large language models.

Prerequisites#

An AI provider must be configured and enabled before this function does anything. See Connect an AI provider.

RW.Tools.AIInsight#

Signature

=RW.Tools.AIInsight(providerName, destination, prompt, [dataRange], [maxTokens])
# Argument Type Default Meaning
1 providerName String required The Name or ProviderId of a configured AI provider, for example "OpenAI". Lookup is case-insensitive.
2 destination String or cell reference required Where the response is written. A string is treated as a TextBox name; a cell reference writes to a cell.
3 prompt String required The prompt sent to the provider.
4 dataRange Range none A range whose values are appended to the prompt as a Markdown table.
5 maxTokens Integer 1000 The maximum output tokens the provider may return, itself capped by the provider's own configured limit.

The first three arguments are required.

How the prompt is built#

The full prompt sent to the provider is assembled in two parts:

  1. The literal text you supplied in prompt.
  2. If dataRange is supplied, a blank line followed by that range rendered as a Markdown table.

That is the whole mechanism. There is no hidden system prompt added by the function itself, and no chunking: the range goes over as a table.

Where the response goes#

A TextBox destination searches every worksheet in the workbook for a TextBox with that name, and replaces its text content with the response. If no TextBox with that name exists anywhere, a warning is logged and the workbook is left unchanged.

A cell destination writes to the top-left cell of the reference you supply. If you pass a range, only its top-left cell is used.

On success the formula cell itself is set to an empty string. The response goes only to the destination, never to the formula cell. On failure the formula cell is set to #VALUE!.

Execution order#

RW.Tools.AIInsight runs after all data-import formulas, after RW.Tools.Sort, and after row suppression. That ordering is deliberate: when you pass a dataRange, the model sees the fully expanded, sorted and suppressed dataset rather than the template's placeholder rows.

Examples#

An AI summary into a TextBox, with data

=RW.Tools.AIInsight("OpenAI", "TextBox1", "Provide a one-paragraph executive summary of this data.", A1:C20, 500)

Calls the OpenAI provider, appends the values in A1:C20 as a Markdown table, and writes the response into the TextBox named TextBox1.

A response into a cell

=RW.Tools.AIInsight("OpenAI", D5, "Summarize the key trends in this range.", A1:C5)

A plain prompt with no data range

=RW.Tools.AIInsight("Azure OpenAI", "CommentaryBox", "What are the top three risks in a declining revenue scenario?")

A larger token budget

=RW.Tools.AIInsight("OpenAI", "SummaryBox", "Summarize this quarter's performance.", B2:F30, 2500)

When an argument is wrong#

Several of these fail quietly, which is worth knowing before you debug a blank TextBox.

Situation Result
providerName, destination or prompt is empty or missing Formula error.
The named provider is not found Error written to the formula cell; the AI call is skipped.
The provider is found but disabled Error written to the formula cell; the AI call is skipped.
No TextBox with the destination name exists Warning logged, workbook unchanged. The formula does not error.
The dataRange worksheet is not found dataRange is silently ignored and the prompt is sent without any table data.
The provider returns an error Error written to the formula cell.

Use cases#

Notes and limits#

Feedback on this page

Comments, questions, requests, or something missing or unclear? Email us - the page you are on is filled in for you.

Email feedback on this page

Or write to support@reportworq.com directly.