Use code interpreter to analyze structured data in Copilot Studio.

By using a code interpreter, Copilot Studio agents can generate and execute Python code as needed in response to user requests.

The code interpreter supports tasks such as statistical analysis, table merging, forecasting, and chart creation. These tasks work with structured files such as CSV and Excel.

Important note :

  1. This article contains preview documentation for Microsoft Copilot Studio and is subject to change.
  2. Preview features are not intended for use in a production environment and may have limited functionality. These features are provided before the official release so you can access them early and provide feedback.
  3. If you're building an agent ready for a production environment, see the Microsoft Copilot Studio Overview .

The benefits of using code interpreters to parse structured data files are:

  1. By using deterministic and reproducible computation, you can unlock reliable analytical capabilities within agents instead of relying on the inherent mathematical and reasoning abilities of large-scale language models to answer analytical questions.
  2. Reduce the skill barrier for advanced analytics by enabling users to ask analytical questions in natural language.
  3. Create tables and visualize results programmatically so that users can view, download, and reuse them.

Copilot Studio agents can use code interpreters to parse structured files provided to the agent in two ways:

  1. As an end user, when you upload structured files while chatting with the agent.
  2. As the creator, when you add the Documents library in SharePoint as a knowledge source, this library contains structured files.

Prerequisites

  1. License : Microsoft Copilot Studio payment and licensing. Code generation and execution are considered features of the AI ​​text generation and creation tool (advanced).
  2. Supported regions : Available for all public clouds. Independent clouds are not currently supported.

The scenarios have been extensively tested.

Microsoft has extensively tested the following scenarios with high reliability.

Note :

  1. If your scenario isn't among those listed in the table, it may still work. The scenarios listed in the tables below reflect a group of scenarios that Microsoft has extensively tested based on predictions of customer usage.
  2. The size limit for each file that can be parsed by the code interpreter, regardless of file type, is 16 MB. You can upload up to 10 files.

Use cases for Excel files (.xlsx)

Type Script description Example 1 Example 2 Example 3
Search - single page Retrieve a specific value, label, or record from a single worksheet in an Excel file. No calculations across multiple rows are required. The answer is directly in the cell/row you're looking for. Includes numeric values, text attributes (name, role, category), and timestamps. Which matches have one team scoring at least three goals? What is the free cash flow in Q4 2024? Which sector does the wholesale fuel segment belong to, starting in Q1 2024?

Use cases for .csv files

Type Script description Example 1 Example 2 Example 3
Search - single file Retrieve a specific value, attribute, or record from a single CSV file. This includes entity lookups (contacts, airports, wind power projects), retrieving values ​​at a specific point in time, and mini-table lookups. No data aggregation between rows is required. Who is the investor of the Sunrise Wind project? How many motorcycles were registered in Tennessee in 1970? Who owns Horseshoe Landings Airport in Keenesburg, CO?
Summary - single file Calculate sums, quantities, differences, group summaries, or look up rankings in a single CSV file. Includes financial summaries, conditional counts, ranking retrieval (maximum/minimum), and group-level summaries returned as numbers, text, or tables. What was the total value of royalties from the sale of onshore oil and gas in 2019? In 2020, how many more trucks were registered in California compared to 2010? What was the total sales revenue achieved by each region in January 2025?
Search - multiple files Combine or match multiple CSV files to retrieve a specific value or list (for example, look up inventory by matching component names in component lists, inventory lists, and price lists; or query emissions data by matching industry names with the main emissions file). How many waterjet cutting machines are currently in the East warehouse? What is the educational price of a 10x24 lathe? How many 3/8-inch drill bits are currently in stock at the East warehouse?
Compilation - multiple files Consolidate or compare data spread across multiple CSV files (for example, sum the total number of employee working hours across monthly CSV files to get a quarterly total, count the number of transactions across annual exported CSV files, or rank industries by emissions across combined files). What was the total number of working hours recorded in the third quarter? What's the earliest time Chris arrives in July? Which industry emitted the most CO2 in 2020?

Use interpreter code to parse structured data files uploaded by the user.

  1. In Copilot Studio, select Settings > Generative AI . Under File processing capabilities , turn on the File uploads toggle switch .
  2. In the File processing capabilities section, turn on the Code interpreter switch .
  3. Select Save .
  4. In the test pane, write a query that asks the agent to perform a calculation using data from a structured data file. Attach the data file to the prompt.

images 1 of Use code interpreter to analyze structured data in Copilot Studio.
Images 1 of Use code interpreter to analyze structured data in Copilot Studio.

Use code interpreter to parse structured data files as SharePoint knowledge sources.

  1. If your agent doesn't already have a SharePoint structured data file as a knowledge source, add this SharePoint file as a knowledge source .
  2. In Copilot Studio, select Settings > Generative AI . In the File processing capabilities section, turn on the Code interpreter toggle .
  3. In the Search section , select Turn on Work IQ .
  4. Select Save .
  5. If you added the SharePoint file following the instructions in the first step, publish your agent.
  6. Test the agent's capabilities by providing a query that requires the agent to perform a calculation in order to provide an answer.
4 | 1 Vote
« PREV : How to build a...