Topic 1 — Create Synthetic Financial Companies Dataset
This first topic creates the foundation of the training package. We will generate two clean CSV files that will later connect to trial balance, financial statements, market data, and ratio fact tables.
Production / Cybersecurity Warning
This exercise uses synthetic data and must be executed only in a practice environment. Do not run scripts in production, real folders, corporate databases, or accounting systems without formal authorization.
Before automating any real financial or accounting process, validate backups, permissions, least-privilege access, change-control approval, sandbox testing, audit requirements, and organizational cybersecurity protocols.
Objective
Create the first two dimension tables of the BI financial model:
Company, ticker, industry, business profile, risk profile, country, and currency.
Fiscal years, quarters, period start months, end months, and period end dates.
Business Scenario
A technical school wants to create a practical BI training where students learn financial ratio analysis from zero. Instead of starting with messy real-world statements, we create a controlled synthetic dataset with realistic business behavior.
| Company | Industry | Financial Behavior | Risk Profile |
|---|---|---|---|
| Alpha Retail Corp | Retail | High revenue, low margin, high inventory | Medium |
| Beta Health Services | Healthcare | Stable revenue, medium margin, low debt | Low |
| Gamma Manufacturing Inc | Manufacturing | High fixed assets, high debt, cyclical revenue | High |
| Delta Tech Solutions | Technology | High margin, low inventory, high valuation | Medium |
| Omega Logistics Group | Logistics | High operating cost, high fixed assets | Medium-High |
Step-by-Step Practice
Step 1 — Create the Working Folder
from pathlib import Path
# Create project folder
base_path = Path("financial_ratios_bi_training")
base_path.mkdir(exist_ok=True)
print(f"Project folder created: {base_path.resolve()}")Step 2 — Import Libraries
import pandas as pd
from pathlib import PathStep 3 — Create Dim_Company
companies_data = [
{
"CompanyID": 1,
"CompanyName": "Alpha Retail Corp",
"Ticker": "ARC",
"Industry": "Retail",
"BusinessProfile": "High revenue, low margin, high inventory",
"RiskProfile": "Medium",
"Country": "United States",
"Currency": "USD"
},
{
"CompanyID": 2,
"CompanyName": "Beta Health Services",
"Ticker": "BHS",
"Industry": "Healthcare",
"BusinessProfile": "Stable revenue, medium margin, low debt",
"RiskProfile": "Low",
"Country": "United States",
"Currency": "USD"
},
{
"CompanyID": 3,
"CompanyName": "Gamma Manufacturing Inc",
"Ticker": "GMI",
"Industry": "Manufacturing",
"BusinessProfile": "High fixed assets, high debt, cyclical revenue",
"RiskProfile": "High",
"Country": "United States",
"Currency": "USD"
},
{
"CompanyID": 4,
"CompanyName": "Delta Tech Solutions",
"Ticker": "DTS",
"Industry": "Technology",
"BusinessProfile": "High margin, low inventory, high valuation",
"RiskProfile": "Medium",
"Country": "United States",
"Currency": "USD"
},
{
"CompanyID": 5,
"CompanyName": "Omega Logistics Group",
"Ticker": "OLG",
"Industry": "Logistics",
"BusinessProfile": "High operating cost, high fixed assets",
"RiskProfile": "Medium-High",
"Country": "United States",
"Currency": "USD"
}
]
dim_company = pd.DataFrame(companies_data)
dim_companyStep 4 — Export Dim_Company to CSV
output_path = Path("financial_ratios_bi_training")
dim_company.to_csv(output_path / "Dim_Company.csv", index=False)
print("Dim_Company.csv created successfully.")Step 5 — Create Dim_Period
We create fiscal periods from 2021 Q1 through 2025 Q4. That gives us 5 years, 4 quarters per year, and 20 fiscal periods.
periods = []
period_id = 1
for year in range(2021, 2026):
for quarter in range(1, 5):
if quarter == 1:
start_month = 1
end_month = 3
period_end = f"{year}-03-31"
elif quarter == 2:
start_month = 4
end_month = 6
period_end = f"{year}-06-30"
elif quarter == 3:
start_month = 7
end_month = 9
period_end = f"{year}-09-30"
else:
start_month = 10
end_month = 12
period_end = f"{year}-12-31"
periods.append({
"PeriodID": period_id,
"FiscalYear": year,
"FiscalQuarter": f"Q{quarter}",
"YearQuarter": f"{year} Q{quarter}",
"QuarterNumber": quarter,
"PeriodStartMonth": start_month,
"PeriodEndMonth": end_month,
"PeriodEndDate": period_end
})
period_id += 1
dim_period = pd.DataFrame(periods)
dim_periodStep 6 — Export Dim_Period to CSV
dim_period.to_csv(output_path / "Dim_Period.csv", index=False)
print("Dim_Period.csv created successfully.")Step 7 — Validate the Output
print("Dim_Company rows:", len(dim_company))
print("Dim_Period rows:", len(dim_period))
print("\nCompanies:")
print(dim_company[["CompanyID", "CompanyName", "Industry", "RiskProfile"]])
print("\nPeriods:")
print(dim_period[["PeriodID", "YearQuarter", "PeriodEndDate"]].head())
print(dim_period[["PeriodID", "YearQuarter", "PeriodEndDate"]].tail())Step 8 — Check the Created Files
for file in output_path.glob("*.csv"):
print(file.name)Expected Output
Dim_Company rows: 5
Dim_Period rows: 20
Created files:
Dim_Company.csv
Dim_Period.csvBusiness Interpretation
At this point, we already have the foundation of the BI model. Dim_Company tells us who we are analyzing. Dim_Period tells us when we are analyzing.
Later, every fact table will connect to these two dimensions: Trial Balance, Income Statement, Balance Sheet, Cash Flow, Market Data, and Financial Ratios.
Final Result of Topic 1
financial_ratios_bi_training/
Dim_Company.csv
Dim_Period.csvNext topic: Topic 2 — Create the Chart of Accounts.