How gokulrnair7/sankalp-industries-budget-vs-actual-variance-analysis works
Purpose and Entry Points
This repository is an end-to-end operating-expense budget-versus-actual variance analysis for a synthetic enterprise. Its pipeline generates a star-schema dataset, loads and cleans it in SQL Server, then presents the governed results in Excel and Power BI.
Primary execution order:
• src/generate_dataset.py
• sql/01_create_and_load.sql
• sql/02_data_cleaning.sql
• sql/03_analysis.sql
Synthetic Data Generation
src/generate_dataset.py is the upstream source of the analytical dataset. It produces:
• data/fact_budget_actuals.csv
• data/dim_account.csv
• data/dim_department.csv
The fact records monthly budget and actual spend; dimensions define accounts/cost categories and organizational attributes. Generation intentionally injects realistic ERP-like conditions: null actuals for open periods, duplicates, zero-budget spend, credit notes, renamed accounts, and isolated spikes. These are inputs to downstream data-governance and variance logic, not generation failures.
SQL Server Raw-Landing Boundary
sql/01_create_and_load.sql defines the SQL Server physical schema before CSV import. This is an important boundary: typed database tables protect date, text-code, nullable-actual, and numeric semantics from import-wizard inference.
The source CSVs are imported into raw tables after schema creation. Raw data is retained as the audit-preserving landing layer; downstream consumers should not depend on it for cleaned totals.
Cleaning and Governed Fact View
sql/02_data_cleaning.sql creates vw_clean_fact, the canonical analytical fact layer. It is a view, preserving raw records while centralizing transformations.
The view:
• removes exact business-record duplicates while excluding the surrogate key from duplicate matching;
• repairs consistently swapped date parts;
• marks incomplete/open reporting periods;
• retains null actuals, credit notes, and zero-budget actual spend as meaningful financial events.
vw_clean_fact is the main contract between data preparation and reporting. In particular, open-period filtering must be applied by every aggregate consumer to avoid treating missing/unclosed actuals as a completed-period variance.
Analysis Layer
sql/03_analysis.sql contains the management-analysis queries over the cleaned view and dimensions. Its CTE-based stages support independent inspection of intermediate logic.
The analytical flow calculates headline net variance and absolute variance, then slices results by department, business unit, and cost category. It additionally identifies:
• one-off spend by comparing a cost line to its own monthly baseline;
• material variances requiring both percentage and rupee thresholds;
• unbudgeted spend;
• cumulative year-to-date variance.
This separates persistent control or planning issues from exceptional events and prevents small high-percentage misses or large low-significance values from dominating review.
Reporting Consumers
excel/Sankalp_Variance_Analysis.xlsx is a formula-driven executive-analysis artifact. Its budget and actual inputs feed reconciled variance, bridge, and summary views from a single source area.
powerbi/Sankalp_Variance_Dashboard.pbix is the interactive reporting layer. It connects directly to SQL Server’s cleaned fact view and the two dimensions, rather than reimplementing cleaning in Power BI. The model uses one-to-many dimension-to-fact filtering and supports fiscal/calendar and organization slicers.
The Power BI file depends on a local SQL Server connection for refresh, although cached data is embedded.
Runtime and Infrastructure
Material runtimes are Python with pandas/numpy for generation and Microsoft SQL Server/SSMS for storage, import, cleaning, and querying. Excel and Power BI are downstream desktop BI clients.
The primary operational dependency is the SQL Server database connection: it hosts raw tables, vw_clean_fact, and the dimensional model consumed by Power BI. Data files under data/ are reproducible seed artifacts, while the Excel workbook and .pbix are presentation endpoints.
Main entry points: 01_create_and_load.sql Schema and raw load · generate_dataset.py Synthetic dataset generator · 03_analysis.sql Management analysis · fact_budget_actuals.csv Budget actuals CSV
Components 14
Data Generation
- Synthetic dataset generator · Creates reproducible ERP-like budget and actual data conditions.
src/generate_dataset.py - Budget actuals CSV
data/fact_budget_actuals.csv - Account CSV
data/dim_account.csv - Department CSV
data/dim_department.csv
SQL Server
- Schema and raw load · Defines typed physical tables before CSV import.
sql/01_create_and_load.sql - Raw fact table · Retains imported records before governed transformations.
- Raw dimension tables
- Cleaning logic · Centralizes duplicate, date, and reporting-period handling.
sql/02_data_cleaning.sql - Clean fact view · Aggregate consumers must filter open reporting periods.
- Management analysis · Calculates variance, materiality, one-off, unbudgeted, and YTD views.
sql/03_analysis.sql - Variance insights
Reporting
- Executive workbook · Formula-driven variance, bridge, and summary views.
excel/Sankalp_Variance_Analysis.xlsx - Interactive dashboard · Refreshes from the local SQL Server model; cached data is embedded.
powerbi/Sankalp_Variance_Dashboard.pbix - Star-schema BI model · Uses one-to-many account and department filtering.
Connections 17
- Synthetic dataset generator → Budget actuals CSV: generates
- Synthetic dataset generator → Account CSV: generates
- Synthetic dataset generator → Department CSV: generates
- Budget actuals CSV → Schema and raw load: imports
- Account CSV → Schema and raw load: imports
- Department CSV → Schema and raw load: imports
- Schema and raw load → Raw fact table: lands
- Schema and raw load → Raw dimension tables: lands
- Raw fact table → Cleaning logic: source records
- Cleaning logic → Clean fact view: creates
- Clean fact view → Management analysis: governed facts
- Raw dimension tables → Management analysis: dimensions
- Management analysis → Variance insights: produces
- Clean fact view → Star-schema BI model: fact source
- Raw dimension tables → Star-schema BI model: dimension sources
- Star-schema BI model → Interactive dashboard: powers
- Executive workbook → Variance insights: presents reconciled views