How to create a reusable Prompt Template in Fabric Copilot
This tutorial shows how to create a reusable prompt template in Fabric Copilot to automate repetitive tasks — useful to standardize analyses, clean data and speed up consistent responses. You will learn why to use the template and how to implement it step by step, with a practical example.
Prerequisites
- Account with access to Microsoft Fabric and permissions to use Copilot.
- Simple dataset in OneLake or in the Warehouse (CSV with columns like: id, name, value, date).
- Basic knowledge of prompts and how to open Copilot in the Fabric interface.
Step 1: Define the template goal
Before writing, clarify what the template will do (e.g.: clean null values, standardize dates, generate summary by category). Defining the goal avoids ambiguity in Copilot and allows creating variables in the template.
Step 2: Create the template structure
Open Copilot in Fabric and select conversation mode to create a new prompt. Use a clear structure with placeholders between << >> for variables you will fill later (for example, column, format, rule). This allows reusing the same prompt for different columns or datasets.
Template: Limpeza e resumo de coluna
Objetivo: Limpar NULLs, padronizar formato e criar resumo estatístico.
Instruções:
- dataset: <>
- coluna alvo: <>
- formato data (se aplicável): <>
Tarefas:
1) Identificar valores nulos e frequências.
2) Substituir nulos por: <>.
3) Converter formato de data para <> (se coluna for data).
4) Gerar resumo: count, unique, nulls, mean/median (se numérico).
Produzir saída: passo a passo + código sugerido (SQL ou Python).
Step 3: Test the template with a simple example
Fill the placeholders with concrete values and ask Copilot to generate the code. Use a test dataset to validate the instructions. Request SQL if working in the Warehouse or Python/PySpark if using Notebooks.
Exemplo de preenchimento:
<> = /OneLake/Marketing/sales.csv
<> = data_venda
<> = yyyy-MM-dd
<> = 1970-01-01
Prompt final: (cole o template preenchido no Copilot)
Step 4: Refine for common errors
Review Copilot's response and request adjustments. Common errors: assumptions about data types, different date formats, or columns mixing text/numbers. Adjust the template to include validations (e.g.: check regex, show examples of problematic values).
Adição ao template para validação:
- Mostrar até 10 exemplos de valores inválidos.
- Se mais de 10% inválidos, avisar e não aplicar transformação automática.
Step 5: Create variants for SQL and Notebooks
Create two variants of the same template: one that requests SQL compatible with Fabric Warehouse and another that requests Python/PySpark code for Notebooks. Keep the placeholders identical to facilitate reuse.
SQL variant snippet (exemplo gerado pelo Copilot):
SELECT
COUNT(*) AS total,
SUM(CASE WHEN data_venda IS NULL THEN 1 ELSE 0 END) AS nulls,
MIN(data_venda) AS min_date,
MAX(data_venda) AS max_date
FROM OPENROWSET('/OneLake/Marketing/sales.csv') AS t;
Verify the result
Confirm the template works by applying the variant to the test dataset: verify that transformations occurred (nulls replaced, formats normalized) and that the statistical summary matches expectations. Test with another column to ensure reuse. Record any warning messages the template returns (e.g.: high percentage of invalid values).
Conclusion
After creating and testing the template, you can save it and share it with the team to standardize cleaning and analysis tasks in Fabric Copilot. Next steps: add meta-instructions to handle languages or create more advanced templates with conditional logic. Tip: keep placeholders consistent and document example fillings for each template.