
KPI Dashboard Automation — Technical Implementation Guide
Architecture Overview
code
[12 Gov Systems] → [ETL Python Script] → [PostgreSQL] → [Power BI] → [AI Summary Layer] → [Email Delivery]
Step 1: Data Source Inventory
Before building, document every data source:
- System name
- Data available (what KPIs can be extracted)
- Access method (API, database, file export, scrape)
- Refresh frequency
- Data owner and access approval path
Step 2: ETL Pipeline Setup
python
# Example: Python ETL with scheduling
import schedule
import pandas as pd
from sqlalchemy import create_engine
def run_etl():
# Connect to each source system
# Transform and standardise data
# Load into central PostgreSQL warehouse
pass
# Run nightly at 3AM
schedule.every().day.at('03:00').do(run_etl)
Step 3: Power BI Dashboard Build
- Connect Power BI to your PostgreSQL warehouse
- Build the core KPI views (current vs target, trend, entity comparison)
- Use consistent colour coding: Green = on track, Amber = at risk, Red = critical
- Add drill-through pages for each KPI domain
- Enable scheduled refresh (daily at 6AM)
Step 4: AI Executive Summary Generation
python
import openai
def generate_executive_summary(kpi_data_json):
prompt = f"""
You are a senior government analyst. Based on the following KPI data for today,
write a concise executive briefing note (max 200 words) covering:
- Overall status (1 sentence)
- Top 3 achievements
- Top 3 concerns requiring leadership attention
- Recommended focus areas for today
KPI Data: {kpi_data_json}
"""
response = openai.chat.completions.create(
model='gpt-4o',
messages=[{'role': 'user', 'content': prompt}]
)
return response.choices[0].message.content
Step 5: Automated Email Delivery
- Use Power Automate or Python smtplib to send the report
- Schedule delivery at 7:00 AM to leadership distribution list
- Include Power BI embedded screenshot + AI summary in email body
- Link to full interactive dashboard in email footer