How to create a Prompt Chain with Copilot in Fabric: step by step
This tutorial shows how to create a Prompt Chain in Copilot in Fabric to automate a sequence of analyses on a dataset (simple cleaning → summarization → metric suggestions). A Prompt Chain enables repeatable flows, reduces errors, and speeds up data exploration with Copilot in Fabric.
Prerequisites
- Account with access to Microsoft Fabric and permissions to use Copilot.
- Workspace with a simple Dataset (CSV) uploaded to OneLake or in Dataflow Gen2.
- Basic knowledge of prompts and how to open Copilot in Fabric.
Step 1: Design the Prompt Chain task sequence
Before opening Copilot, define the steps the chain will perform. In this example we will: (1) detect and normalize null/duplicate values, (2) generate a textual summary of the columns and (3) suggest 3 key metrics to present in a report.
Step 2: Open Copilot and create a new Prompt Chain
Open Copilot in Fabric and choose the option to create a new Prompt Chain (or Template, if available). Give it a clear name, for example: "Chain_Limpeza_Sumario_Metricas". Explain in the description field the objective and the expected inputs (dataset, key column).
Step 3: Create Step 1 — Basic cleaning
Add the first step of the chain with a prompt that handles nulls and duplicates. Indicate the input format (e.g., CSV with columns). Use clear commands and examples so Copilot knows what we want.
// Exemplo de prompt para Step 1
"Recebe o dataset como tabela. Identifica colunas com >5% de valores nulos. Remove linhas duplicadas com base na coluna 'id'. Substitui nulos em colunas numéricas pela mediana e em colunas de texto por 'Desconhecido'. Retorna a tabela limpa."
Step 4: Create Step 2 — Column summarization
Add the second step that receives the cleaned table from Step 1 and generates a summary per column: type, count of distinct values, percentage of nulls (should be 0 after cleaning) and 3 example values.
// Exemplo de prompt para Step 2
"A partir da tabela limpa, para cada coluna devolve: nome, tipo (numérico/texto/data), contagem distinct, percentagem de nulos e até 3 exemplos de valores. Formata a resposta como JSON."
Step 5: Create Step 3 — Suggest metrics
The third step should analyze the cleaned table and the summary from Step 2 to suggest 3 actionable metrics (e.g., conversion rate, average by category). Also ask for a brief rationale for each metric and an example of recommended visualization.
// Exemplo de prompt para Step 3
"Com base nos dados e no resumo, sugere 3 métricas relevantes para monitorizar. Para cada métrica devolve: nome, fórmula (colunas usadas), por que é importante, e tipo de visualização recomendada (ex.: bar chart, time series). Responde em JSON."
Step 6: Connect inputs/outputs and test the Chain
Define the connections between steps: output of Step 1 → input of Step 2 and Step 3. If Copilot allows, add validations (e.g., ensure the 'id' column exists). Run the Prompt Chain on a fragment of the dataset to test behavior before running on the full table.
// Exemplo de sequência lógica
Input (dataset.csv) -> Step 1 (limpeza) -> cleaned_table
cleaned_table -> Step 2 (sumário) -> summary_json
cleaned_table + summary_json -> Step 3 (métricas) -> metrics_json
Step 7: Iterate and refine prompts (common errors)
If results are not as expected, adjust the prompts: specify formats (JSON), response examples or set limits (e.g., do not drop entire columns). Common errors: ambiguous instructions, lack of examples and forgetting to correctly map outputs between steps.
Verify the result
Confirm the Prompt Chain works by checking: (1) the output table from Step 1 has less than or equal number of rows and no duplicates, (2) the JSON from Step 2 lists all columns and coherent types and (3) the JSON from Step 3 suggests 3 metrics with valid formulas. Test with a known dataset to validate calculations.
Conclusion
A Prompt Chain in Copilot in Fabric allows automating sequential data preparation and analysis tasks, making repetitive processes more reliable. Next steps: integrate the chain into a Dataflow Gen2 pipeline or schedule executions. Tip: document each step with input/output examples to ease maintenance and sharing — what is the first dataset you want to automate with a Prompt Chain?